Skip to content
Myr

waitress.rst

This file

Path

docs/deploying/waitress.rst

75 lines · 2.3 KiB

Last changed by

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

History of this file

Take it

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 1–29why, one step back
1Waitress
2========34`Waitress`_ is a pure Python WSGI server.56* It is easy to configure.7* It supports Windows directly.8* It is easy to install as it does not require additional dependencies9 or compilation.10* It does not support streaming requests, full request data is always11 buffered.12* It uses a single process with multiple thread workers.1314This page outlines the basics of running Waitress. Be sure to read its15documentation and ``waitress-serve --help`` to understand what features16are available.1718.. _Waitress: https://docs.pylonsproject.org/projects/waitress/192021Installing22----------2324Create a virtualenv, install your application, then install25``waitress``.2627.. code-block:: text2829 $ cd hello-app

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

lines 30–31why, one step back
30 $ python -m venv .venv
31 $ . .venv/bin/activate

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 32–47why, one step back
32 $ pip install . # install your application
33 $ pip install waitress343536Running37-------3839The only required argument to ``waitress-serve`` tells it how to load40your Flask application. The syntax is ``{module}:{app}``. ``module`` is41the dotted import name to the module with your application. ``app`` is42the variable with the application. If you're using the app factory43pattern, use ``--call {module}:{factory}`` instead.4445.. code-block:: text4647 # equivalent to 'from hello import app'

Merge branch '2.2.x'David Lordbefore adoption73b9bac

line 48why, one step back
48 $ waitress-serve --host 127.0.0.1 hello:app

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 49–50why, one step back
49
50 # equivalent to 'from hello import create_app; create_app()'

Merge branch '2.2.x'David Lordbefore adoption73b9bac

line 51why, one step back
51 $ waitress-serve --host 127.0.0.1 --call hello:create_app

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 52–75why, one step back
52
53 Serving on http://127.0.0.1:80805455The ``--host`` option binds the server to local ``127.0.0.1`` only.5657Logs for each request aren't shown, only errors are shown. Logging can58be configured through the Python interface instead of the command line.596061Binding Externally62------------------6364Waitress should not be run as root because it would cause your65application code to run as root, which is not secure. However, this66means it will not be possible to bind to port 80 or 443. Instead, a67reverse proxy such as :doc:`nginx` or :doc:`apache-httpd` should be used68in front of Waitress.6970You can bind to all external IPs on a non-privileged port by not71specifying the ``--host`` option. Don't do this when using a revers72proxy setup, otherwise it will be possible to bypass the proxy.7374``0.0.0.0`` is not a valid address to navigate to, you'd use a specific75IP address in your browser.