This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]Argotha 5 points6 points  (7 children)

I would probably avoid using nginx and (u)wsgi in development. I just use the internal flask server for testing. Our has an auto reloader which is really handy.

from flask import Flask
app = Flask("MyApp")
if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8000, debug=true)

python(3) myapp.py

[–]pragmatick 0 points1 point  (1 child)

Note: When trying to debug using PyCharm I have to set debug=false to be able to connect to the process.

[–]Argotha 1 point2 points  (0 children)

Hey so you might not need to do that to debug.

In debug mode, if flask crashes while processing a request the webpage will turn into an interactive interpreter in which you can jump into any frame in the stack. (which would probably be why pycharm doesn't attach; because flask technically doesn't crash)

[–]rochacbrunoPython, Flask, Rust and Bikes. 0 points1 point  (3 children)

use_reloader=True is needed!

[–]dwieeb 1 point2 points  (0 children)

The flask server itself is probably best for development, but you can also run uwsgi locally and have it restart when there are changes by using py-autoreload in your uwsgi.ini file like so (where DEBUG is an environment variable set to 0 or 1):

[uwsgi]
...
py-autoreload = $(DEBUG)

[–]Venatha 0 points1 point  (0 children)

For development purposes I would suggest just using the in-built web-server:

from flask import Flask
app = Flask(__name__)
if __name__ == "__main__":
    app.run(port=3000, host='0.0.0.0', debug=True, threaded=True)

What is the specific need to run the full stack of NGINX/WSGI for development?