服务Flask应用程序是否需要WSGI服务器和HTTP服务器?

问题描述:

使用uWSGI和Nginx设置Flask相当困难,即使使用扩展脚本也需要花费一些时间,并且必须记录到指令中以备后用.

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 later.

如果我不打算在服务器上增加很大的负载(它对公共隐藏),那么在没有uWSGI的情况下运行它是否有意义? (Flask可以监听端口.Nginx可以转发请求吗?)

If I don't plan a big load on server (it's hidden from public), does it make sense to run it without uWSGI? (Flask can listen to a port. Can Nginx just forward requests?)

只在端口上运行裸瓶应用程序,甚至不使用Nginx有意义吗?

Does it make sense to not use even Nginx, just running bare flask app on a port?

当您运行Flask"时,您实际上是在运行Werkzeug的开发WSGI服务器,并将Flask应用程序作为可调用的WSGI传递.

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

开发服务器不适用于生产环境.它的设计目的不是特别高效,稳定或安全.它不支持HTTP服务器的所有可能功能.

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.

无论何时何地使用该应用程序,都将Werkzeug开发服务器替换为可投入生产的WSGI服务器,例如Gunicorn或uWSGI,

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.

对于我应该使用Web服务器",答案是相似的. WSGI服务器恰好具有HTTP服务器,但不如专用的生产HTTP服务器(Nginx,Apache等)好.

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 文档如何以各种方式进行部署.许多托管服务提供商还提供了有关部署Python或Flask的文档.

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