close
Skip to content

hasansezertasan/a2wsgi-examples

Repository files navigation

a2wsgi Examples

The purpose of this project is to provide examples of how we can use (integrate) different Python Web Frameworks together using a2wsgi.

Why

Who likes migration? But in some cases, it's necessary. a2wsgi helps us to convert our ASGI applications to WSGI or vice versa.

A Scenario (that I have faced): You have a Flask application and you want to migrate it to FastAPI. You have two options:

  1. Rewrite the whole application from scratch and deploy it when it's ready.
  2. Use a2wsgi to convert your Flask application to WSGI using a2wsgi and then integrate (mount) it to your FastAPI application and deploy it. By the time, you can rewrite your application step by step.

Progress

Frameworks

Framework Mount Protocol Notes
Flask WSGI Full app with cookie endpoints
FastAPI ASGI Full app with cookie endpoints
Django WSGI
Starlette ASGI
Litestar ASGI
BlackSheep ASGI ASGI shim — requires own lifecycle for full app mount
Quart ASGI
Falcon WSGI
Sanic ASGI ASGI shim — manages own event loop
Connexion ASGI Fallback shim when not installed
Bottle WSGI
Robyn WSGI WSGI shim — no WSGI/ASGI adapter available
HUG WSGI
Tornado WSGI WSGI shim — runs own IOLoop, no adapter
Pyramid WSGI
webapp2 WSGI Fallback shim when not installed
aiohttp ASGI ASGI shim — no native ASGI sub-app mounting

Other tools

Framework Mount
Gradio
PyWebIO
Flet
NiceGUI 🚧
Reflex 🚧
Streamlit 🔳
Plotly Dash 🔳

Emoji key:

  • ✅: Accomplished
  • 🔳: Not tried yet
  • ❌: Tried and failed
  • 🚧: In progress
  • ⚠️: Not sure if possible

How to run

Requirements

  • Python 3.10+
  • uv
  • Docker & Docker Compose (optional)

Local development

uv sync
uv run uvicorn app.main:app --reload

Docker

docker compose up --build

Go to http://localhost:8000/docs to see the API documentation.

Running tests

uv run pytest tests/ -v

Contributing

If you would like to contribute to this project, please open an issue or submit a pull request.

Further Reading

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

The goal of this project is to provide examples about integrating different Python Web Frameworks and how they can be used together with a2wsgi.

Topics

Resources

License

Stars

Watchers

Forks

Contributors