Simplify flask.cli.main
Werkzeug>=0.15's reloader now properly detects `python -m module`. Fixes #3022
This commit is contained in:
parent
5a49b96d0e
commit
e0afff0e92
2 changed files with 4 additions and 17 deletions
18
flask/cli.py
18
flask/cli.py
|
|
@ -907,23 +907,7 @@ debug mode.
|
|||
|
||||
|
||||
def main(as_module=False):
|
||||
args = sys.argv[1:]
|
||||
|
||||
if as_module:
|
||||
this_module = "flask"
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
this_module += ".cli"
|
||||
|
||||
name = "python -m " + this_module
|
||||
|
||||
# Python rewrites "python -m flask" to the path to the file in argv.
|
||||
# Restore the original command so that the reloader works.
|
||||
sys.argv = ["-m", this_module] + args
|
||||
else:
|
||||
name = None
|
||||
|
||||
cli.main(args=args, prog_name=name)
|
||||
cli.main(prog_name="python -m flask" if as_module else None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue