Last active
May 11, 2023 05:35
-
-
Save jerblack/735b9953ba1ab6234abb43174210d356 to your computer and use it in GitHub Desktop.
Disable ability for Flask to display warning about using a development server in a production environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Flask will display a warning everytime you startup your application if you are not using it in behind a separate WSGI server. | |
* Environment: production | |
WARNING: Do not use the development server in a production environment. | |
Use a production WSGI server instead. | |
This was not relevant for my scenario and I wanted the message gone, | |
so using this method will remove their ability to print that message | |
This method replaces the function they use to write the banner with a no-op. | |
Be aware that this prevents the rest of the Flask startup banner from displaying as well. | |
The only output you will see from the method below is: | |
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit) | |
""" | |
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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that works for me