From 1b06c8a41119f8c93078e85f6474cb85d7e30b43 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 21 Apr 2014 17:52:04 +0200 Subject: [PATCH] Added __main__ module --- flask/__main__.py | 15 +++++++++++++++ flask/run.py | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 flask/__main__.py diff --git a/flask/__main__.py b/flask/__main__.py new file mode 100644 index 00000000..e3c3bd34 --- /dev/null +++ b/flask/__main__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +""" + flask.__main__ + ~~~~~~~~~~~~~~ + + Alias for flask.run for the command line. + + :copyright: (c) 2014 by Armin Ronacher. + :license: BSD, see LICENSE for more details. +""" + + +if __name__ == '__main__': + from run import main + main(as_module=True) diff --git a/flask/run.py b/flask/run.py index 89344616..9d86df02 100644 --- a/flask/run.py +++ b/flask/run.py @@ -1,3 +1,14 @@ +# -*- coding: utf-8 -*- +""" + flask.run + ~~~~~~~~~ + + A simple command line application to run flask apps. + + :copyright: (c) 2014 by Armin Ronacher. + :license: BSD, see LICENSE for more details. +""" + import os import sys from threading import Lock @@ -164,7 +175,10 @@ def main(as_module=False): this_module = __package__ + '.run' if as_module: - name = 'python -m ' + this_module + if sys.version_info >= (2, 7): + name = 'python -m ' + this_module.rsplit('.', 1)[0] + else: + name = 'python -m ' + this_module else: name = 'flask-run'