I'm investigating how to develop a decent web app with Python. Since I don't want some high-order structures to get in my way, my choice fell on the lightweight Flask framework. Time will tell if this was the right choice.
So, now I've set up an Apache server with mod_wsgi, and my test site is running fine. However, I'd like to speed up the development routine by making the site automatically reload upon any changes in py or template files I make. I see that any changes in site's .wsgi file causes reloading (even without WSGIScriptReloading On in the apache config file), but I still have to prod it manually (ie, insert extra linebreak, save). Is there some way how to cause reload when I edit some of the app's py files? Or, I am expected to use IDE that refreshes the .wsgi file for me?
Best Answer
The current recommended way is with the
flask
command line utility.https://flask.palletsprojects.com/en/1.1.x/quickstart/#debug-mode
Example:
or in one command:
If you want different port than the default (
5000
) add--port
option.Example:
More options are available with:
FLASK_APP
can also be set tomodule:app
ormodule:create_app
instead ofmodule.py
. See https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery for a full explanation.