运行 Flask 时的警告消息 [英] Warning message while running Flask
问题描述
当我从命令行运行 Flask 代码时,出现警告:
While I am running Flask code from my command line, a warning is appearing:
Serving Flask app "hello_flask" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
这是什么意思?
推荐答案
如 Flask 中所述文档:
虽然轻量级且易于使用,但 Flask 的内置服务器不适合生产,因为它不能很好地扩展并且默认一次只处理一个请求.
While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well and by default serves only one request at a time.
鉴于 Web 应用程序需要处理来自多个用户的多个并发请求,Flask 警告您开发服务器不会这样做(默认情况下).它建议使用 Web 服务器网关接口 (WSGI) 服务器 (部署文档中列出了许多可能性,每个可能性都有进一步的说明),它们将用作您的 Web/应用程序服务器并调用 Flask因为它服务于请求.
Given that a web application is expected to handle multiple concurrent requests from multiple users, Flask is warning you that the development server will not do this (by default). It recommends using a Web Server Gateway Interface (WSGI) server (numerous possibilities are listed in the deployment docs with further instructions for each) that will function as your web/application server and call Flask as it serves requests.
这篇关于运行 Flask 时的警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!