Built for speed and clarity.
Faster by design 🚀
Flameo speaks Granian's native RSGI protocol and also supports Uvicorn/Hypercorn's ASGI protocol. On benchmark it beats the likes of FastAPI, Robyn and Sanic.
Named dependencies, not plumbing
Type db, cache, app or state in the handler signature and the managed object arrives.
No framework under the framework
The core framework depends only on orjson, pydantic and uvloop (on Linux and macOS). No Starlette, no ASGI toolkit, no wrapper around a wrapper. What you write is what you debug.
Batteries included
Managed DB and cache pools, pydantic validation with file uploads, sessions, static files, templates, rate limiting, compression, CORS and OpenAPI docs all out of the box.
Ask for it by name.
Add db, cache, app or state to a handler and Flameo injects the managed handle. No reaching through req.app.state, no manual pool setup required across PostgreSQL, MySQL, Oracle, SQLite, MongoDB.cache works seamlessly both with and without Redis
@app.get("/users")
async def get_users(req, res, db):
rows = await db.fetch("SELECT id, name FROM users")
await res.json(rows)
@app.get("/visits")
async def visits(req, res, cache):
total = await cache.incr("visits")
await res.json({"visits": total})
@app.get("/counter")
async def counter(req, res, state):
state.visits = (state.visits or 0) + 1
await res.json({"visits": state.visits})
db, cache and state can coexist. You can also add other dependencies on your own.
One model. JSON or multipart.
In Flameo, pydantic validation also works with files. The same request object can hold File fields.
from pydantic import BaseModel
from flameo import File
class Product(BaseModel):
title: str
price: float
photo: File
description: str
@app.post("/listings")
async def create_listing(data: Product, res):
#your logic here
await res.json({"title": data.title, "photo": data.photo.filename}, status=201)
You can also include Optional[File], List[File] or even nested models.
Decorate it or register it later.
Views don't have to live inside your app file. Define them in any module, import them into your app and register them by name. Clean code, with setup kept apart from request logic.
from flameo import Flameo
app = Flameo()
@app.get("/hello")
async def hello(req, res):
await res.json({"message": "Hello from Flameo 🔥"})
async def hello(req, res):
await res.json({"message": "Hello again"})
from flameo import Flameo
from views import *
app = Flameo()
app.get("/hello", hello)
Both works. You can also write the two types in the same file.
Everything you need, already included
without the hassle of assembling packages or writing glue code yourself
Built-in and Custom Middlewares
Global, router and per-route, sync or async.
Built-in Dependency injection
db, cache, app and state parameters.
Pydantic Validation with Files
Pydantic request bodies and uploaded files with structured errors.
Interactive CLI
Project scaffolding, router generation and a Granian RSGI runner.
Template rendering
Built in with Jinja2.
Static files Serving
Built-in serving with ETag and cache validators.
Built-in Compression
Out of the box with gzip, deflate, Brotli and Zstandard.
Response Caching
Built in both with and without Redis, with framework-managed pools.
Rate limiting
Per endpoint or per key.
Lifecycle
Startup and shutdown hooks.
Sessions and CORS
Signed cookies and configurable CORS.
Databases
Framework-managed pools for PostgreSQL, MySQL, Oracle, SQLite and MongoDB.
API docs
OpenAPI with Swagger UI and ReDoc.
Response Streaming
Chunked responses and Server-Sent Events.
Logger
Built-in logging with exact point of source.
Up and running in minutes.
From install to running app in three steps
Install
pip install flameo
Create a Project
flameo startproject myproject
# cd myproject
Run with CLI
#Granian RSGI
flameo run main:app
#uvicorn ASGI
uvicorn main:app
Install only what you need.
| Extra | Adds |
|---|---|
postgres | PostgreSQL driver (asyncpg) |
mysql | MySQL driver (asyncmy + cryptography) |
oracle | Oracle driver (oracledb) |
sqlite | SQLite driver (aiosqlite) |
mongo | MongoDB driver (pymongo) |
database | All five database drivers |
cache | Redis client support (works with Redis, Valkey and Dragonfly) |
templates | Jinja2 template rendering |
compression | Brotli and Zstandard codecs |
test | Test and development dependencies |