Reputation: 251
When running flask app, like
...
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?
Upvotes: 7
Views: 8377
Reputation: 587
I used to get below when I run flask app via python app.py
* Serving Flask app 'app'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
added below code block in my app.py to remove the default flask message completely
import logging
log = logging.getLogger('werkzeug')
log.disabled = True
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None
Upvotes: 2
Reputation: 936
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:
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
Upvotes: 14