Are a WSGI server and HTTP server required to serve a Flask app?

前端 未结 2 1706
谎友^
谎友^ 2020-11-21 05:47

Setting up Flask with uWSGI and Nginx is quite difficult, and even with buildout scripts it takes quite some time, and has to be recorded to instructions to be reproduced la

2条回答
  •  佛祖请我去吃肉
    2020-11-21 05:58

    When you "run Flask" you are actually running Werkzeug's development WSGI server, and passing your Flask app as the WSGI callable.

    The development server is not intended for use in production. It is not designed to be particularly efficient, stable, or secure. It does not support all the possible features of a HTTP server.

    Replace the Werkzeug dev server with a production-ready WSGI server such as Gunicorn or uWSGI when moving to production, no matter where the app will be available.


    The answer is similar for "should I use a web server". WSGI servers happen to have HTTP servers but they will not be as good as a dedicated production HTTP server (Nginx, Apache, etc.).


    Flask documents how to deploy in various ways. Many hosting providers also have documentation about deploying Python or Flask.

提交回复
热议问题