Waitress is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.4+. It is also known to run on PyPy 1.6.0 on UNIX. It supports HTTP/1.0 and HTTP/1.1.
Run with a Production Server
When running publicly rather than in development, you should not use the built-in development server (
flask run). The development server is provided by Werkzeug for convenience but is not designed to be particularly efficient, stable, or secure.
Instead, use a production WSGI server. For example, to use Waitress, first install it in the virtual environment:
pip install waitress
You need to tell Waitress about your application, but it doesn’t use
flask run does. You need to tell it to import and call the application factory to get an application object.
See Deployment Options for a list of many different ways to host your application. Waitress is just an example, chosen for the tutorial because it supports both Windows and Linux. There are many more WSGI servers and deployment options that you may choose for your project.
If your Flask application is called myapplication and the method which instantiates your application is called create_app, then you can simply use:-
waitress-serve --call "myapplication:create_app"
Serving on http://0.0.0.0:8080
This command will launch the server listening on port 8080 by default.
If you wish to launch it on port 80 (http), then all you need to do is:
waitress-serve --port=80 --call "myapplication:create_app"
To check version:
pip show waitress