Closed scolby33 closed 6 years ago
You could do this
@main.command()
@click.option('--host', default='0.0.0.0', help='Flask host. Defaults to localhost')
@click.option('--port', type=int, help='Flask port. Defaults to 5000')
@click.option('--flask-debug', is_flag=True)
@click.option('-v', '--verbose', is_flag=True, help='Verbose output')
def web(host, port, flask_debug, verbose):
"""Run the Flask development server"""
logging.basicConfig(level=(logging.DEBUG if verbose else logging.INFO))
from .web import create_application
create_application().run(host=host, port=port, debug=flask_debug)
so then the flask stuff doesn't imported called unless you're running the web command
The biggest reason not to do that is that the Flask cli's built-in run
command does fun things like auto-reloading the server on code change, which I definitely don't think is worth coding manually.
Fixed to my satisfaction in 6bd4fa5.
I sorta know how to do this but I'm not kidding when I say I think I need to email the Flask mailing list to figure part of it out.