2013-06-24T07:36:05Z
- How To Run A Flask App Mac Command Line Create File
- How To Run A Flask App Mac Command Line Cheat Sheet
- How To Run A Flask App Mac Command Line File
Versions of Flask older than 0.11 used to have different ways to start the application. In short, the flask command did not exist, and neither did python -m flask. In that case you have two options: either upgrade to newer Flask versions or have a look at the Development Server docs to see the alternative method for running a server. The basic way it operates is that when the flask.cli.FlaskGroup executes as a script it creates a script info and keeps it around. From that point onwards modifications on the script info can be done through click options. To simplify this pattern the flask.cli.scriptinfooption decorator was added.
Posted by Miguel Grinberg under Python, Programming, Flask.
I just published a little extension for Flask that exposes some of the options that can be given when calling
app.run()
.Here is the minimal Flask application from the documentation, modified to use this extension:
To use the new commands integrated with Flask cli you must specify on to import your app. Take a look at Flask docs.: # Using the default skeleton application $ export FLASKAPP=app # Using factory app pattern $ FLASKAPP='app:createapp ('config')'. In order to test Flask installation, type the following code in the editor as Hello.py. From flask import Flask app = Flask(name) @app.route('/') def helloworld: return 'Hello World’ if name 'main': app.run Importing flask module in the project is mandatory. An object of Flask class is our WSGI application.
You can see the extension in action by invoking the application with
--help
:To install this extension you can use
pip
:The source code is available on my github.
How To Run A Flask App Mac Command Line Create File
I hope you find it useful!
UPDATE: just added
--profile
and --lint
to enable the Werkzeug profiler and lint middlewares!UPDATE #2: just released version 2.0, which is a rewrite as an extension to Flask-Script. The simple interface described in this article remains available, but a more powerful interface that allows custom commands is also available. See the github page for details.
Miguel
How To Run A Flask App Mac Command Line Cheat Sheet
Hello, and thank you for visiting my blog! If you enjoyed this article, please consider supporting my work on this blog on Patreon!