-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added serve cli command to start default flask server (#112)
* added serve cli command to start default flask server * pep8 fixes * fixed debug param typo * changed behavior of serve without arguments to run default services * updated README.md with new serve command
- Loading branch information
1 parent
8fa3d5f
commit 3c0dd67
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import click | ||
|
||
from ..flask_app import create_app | ||
|
||
|
||
@click.command( | ||
context_settings=dict(help_option_names=['-h', '--help']), | ||
short_help='Start default mapshader server using Flask', | ||
help=( | ||
'Start default mapshader server using Flask' | ||
), | ||
) | ||
@click.argument( | ||
'config_yaml', | ||
type=str, | ||
required=False, | ||
) | ||
@click.option( | ||
'--host', | ||
'host', | ||
default='0.0.0.0', | ||
type=str, | ||
help='Host of Flask server', | ||
) | ||
@click.option( | ||
'--port', | ||
'port', | ||
default=5000, | ||
type=int, | ||
help='Port number of Flask server', | ||
) | ||
@click.option( | ||
'--glob', | ||
'glob', | ||
required=False, | ||
type=str, | ||
help='Filter services to start based on glob', | ||
) | ||
@click.option( | ||
'--debug', | ||
'debug', | ||
is_flag=True, | ||
default=False, | ||
help='Run server in debug mode', | ||
) | ||
def serve(config_yaml=None, host='0.0.0.0', port=5000, glob=None, debug=False): | ||
|
||
from os import path | ||
|
||
if config_yaml: | ||
config_yaml = path.abspath(path.expanduser(config_yaml)) | ||
|
||
create_app(config_yaml, contains=glob).run( | ||
host=host, port=port, debug=debug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters