Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable flask app.run() 's default message?

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?

like image 935
Seung-Woo Lee Avatar asked Dec 13 '22 13:12

Seung-Woo Lee


2 Answers

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

like image 196
user-asterix Avatar answered Jan 07 '23 02:01

user-asterix


try this. export WERKZEUG_RUN_MAIN=true

like image 30
synchalt Avatar answered Jan 07 '23 02:01

synchalt