[英]How to disable flask app.run() 's default message
When running flask app, like运行 flask 应用程序时,如
...
if __name__ is "__main__":
app.run(port=self.port)
...
There are some messages for running.有一些运行消息。
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
How I disable all these messages?我如何禁用所有这些消息?
try this. 尝试这个。 export WERKZEUG_RUN_MAIN=true
导出WERKZEUG_RUN_MAIN = true
To disable Flask from displaying warning banner messsage about using a development server in a production environment, add the 2 cli lines before running flask: 要禁止Flask显示关于在生产环境中使用开发服务器的警告消息,请在运行flask之前添加以下2行:
from flask import Flask
import sys
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None
app = Flask(__name__)
app.run(host='0.0.0.0', port='80')
https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356 https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356
import flask.cli
flask.cli.show_server_banner = lambda *args: None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.