Note: the question was closed as a duplicate but it is not (of neither the questions). I specifically described an app in web mode, then in WSGI mode - I have no doubts on which to use when (both linked questions address this point). I also explained that I know well what a web server is for. The accepted answer makes a good summary of that, and answers the question of whether a web server is a requirement to run a prod flask app (it is not).
I have a flask
application. The development version, with all its limitations, is
import flask
app = flask.Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
app.run()
When I want to move it to production, I use gevent
, per the deployment documentation:
import gevent.monkey
gevent.monkey.patch_all()
import flask
import gevent.wsgi
app = flask.Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
gevent.wsgi.WSGIServer(('127.0.0.1', 5000), app).serve_forever()
Both cases work, with the first one occasionally having issues (which is not unexpected, due to its nature).
Then, a lot of information I read here and there mention that the third component for production deployments of a flask
application is a web server (Apache, nginx). What is its actual use for WSGI-enabled flask applications?
Specifically, I would like to understand whether it has a practical impact on the performance / stability of the flask application.
I know what the various usages of a webserver are (authentication, reverse proxy, whitelisting, rewrites, load management, and many others). My question is specifically about what a webserver provides for a flask WSGI application (if anything).