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
|
|
@ -33,6 +33,9 @@ Unreleased
|
|||
moved into Werkzeug. Use Werkzeug's version with Flask-specific
|
||||
support. This bumps the Werkzeug dependency to >= 0.15.
|
||||
:issue:`3125`
|
||||
- The ``flask`` command entry point is simplified to take advantage
|
||||
of Werkzeug 0.15's better reloader support. This bumps the Werkzeug
|
||||
dependency to >= 0.15. :issue:`3022`
|
||||
|
||||
.. _#2935: https://github.com/pallets/flask/issues/2935
|
||||
.. _#2957: https://github.com/pallets/flask/issues/2957
|
||||
|
|
|
|||
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