Falcon Web Framework

4.2.0 · active · verified Sun Apr 12

Falcon is a minimalist, high-performance Python web API framework for building REST APIs and microservices. It provides a clean design that embraces HTTP and the REST architectural style, with a strong focus on reliability, correctness, and speed. The current version, 4.2.0, primarily contains typing enhancements and performance optimizations, including support for free-threaded CPython 3.14. Falcon supports both synchronous (WSGI) and asynchronous (ASGI) applications and typically follows a stable release cadence with regular updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a simple WSGI Falcon application. It defines a resource with an `on_get` method to handle GET requests to the `/quote` endpoint, returning a JSON response. The `falcon.App()` instance is then created and the resource is attached to a route. To serve this application, a WSGI server like Gunicorn is typically used. For ASGI applications, `falcon.asgi.App` and `async` responder methods would be used.

import falcon

class QuoteResource:
    def on_get(self, req: falcon.Request, resp: falcon.Response) -> None:
        """Handles GET requests."""
        resp.status = falcon.HTTP_200
        resp.media = {
            'quote': "I've always been more interested in the future than in the past.",
            'author': 'Grace Hopper',
        }

# Instantiate a WSGI Falcon application
app = falcon.App()

# Create an instance of our resource
quotes = QuoteResource()

# Add a route to our application
app.add_route('/quote', quotes)

# To run this, save as `app.py` and then run:
# pip install gunicorn
# gunicorn app:app
# Then access via curl: curl http://127.0.0.1:8000/quote

view raw JSON →