A tiny WSGI web framework written from scratch, for learning. The goal was to mash together the parts I like from Django and FastAPI: Django's declarative models/ORM and template rendering, and FastAPI's lightweight decorator-based routing.
- Decorator routing (
@app.route("/")), FastAPI-style, with path params viaparse(e.g."/users/{id}"). - Function and class-based views — a class handler dispatches on HTTP method (
get,post, ...), Django-style. - A baby ORM — declare models with
CharField/IntegerField, call.save(), and tables auto-migrate on startup. - SQLite-backed, no config needed (
db.sqlite3by default). - Jinja2 templates via
app.render_template(...). - Response types:
HttpResponse,JsonResponse,HTMLResponse. - Pluggable middleware stack (toggle with
Config(activate_middleware=...)). - WSGI compatible — runs under gunicorn or any WSGI server.
| From FastAPI | From Django |
|---|---|
@app.route decorator routing |
Model + Field declarative ORM |
Single app callable object |
class Meta: app = app model config |
| Lightweight, minimal boilerplate | Auto-migrations on model registration |
JsonResponse for APIs |
Jinja2 template rendering + base templates |
from api import API
from config import Config
from http.types import HttpRequest, HttpResponse
from orm.models import Model, IntegerField, CharField
from utils import bind_json_to_class
app = API(config=Config(activate_middleware=False, template_dirs=["templates"]))
@app.model()
class User(Model):
age = IntegerField(default=100)
name = CharField()
class Meta:
app = app
@app.route("/")
def home(request: HttpRequest):
user = bind_json_to_class(User, request.body)
user.save()
return HttpResponse("Hello World")gunicorn app:appA learning project.