The FastAPI package is supported in Python Workers.
FastAPI applications use a protocol called the Asynchronous Server Gateway Interface (ASGI) ↗. This means that FastAPI never reads from or writes to a socket itself. An ASGI application expects to be hooked up to an ASGI server, typically uvicorn ↗. The ASGI server handles all of the raw sockets on the application’s behalf.
The Workers runtime provides an ASGI server ↗ directly to your Python Worker, which lets you use FastAPI in Python Workers.
Get Started
Clone the cloudflare/python-workers-examples repository and run the FastAPI example:
Example code
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!