Python Falcon - Environment Setup



The latest version of Falcon requires Python 3.5 or newer version. The easiest as well as recommended way to install Falcon is with PIP installer, preferably in a virtual environment.

The latest stable version can be installed by running the following command −

pip3 install falcon

To verify if the installation has been performed successfully, import the library and check its version.

>>> import falcon
>>>falcon.__version__
'3.1.0'

To install the latest beta version, following command should be used −

pip3 install --pre falcon

Right from the early version, Falcon supports WSGI. A Falcon app can be run with the help of built-in WSGI server in Python's standard library module wsgiref. However, it is not suitable for production environment, for which WSGI servers such as gunicorn, waitress or uwsgi are required.

For Falcon on Windows, one can use Waitress, a production-quality, pure-Python WSGI server. As usual, install it with pip installer.

pip3 install waitress

The Gunicorn server can't be installed on Windows. However, it can be used inside a Windows Subsystem Linux (WSL) environment on Windows 10. For using gunicorn on Linux, WSL or inside Docker containers, use

pip3 install gunicorn

If you want to run an asynchronous Falcon app, an ASGI compliant application server is required. The Uvicorn server can be used on Windows as well as Linux systems.

pip3 install uvicorn
Advertisements