This is not a framework
# app.py
from tina4_python.core import run
from tina4_python.core.router import get
@get("/hello")
async def hello(request, response):
return response({"message": "Hello World!"})
run() # starts on port 7145
Click Try It to deploy working example code into your src/ folder
Define routes with one decorator
@get("/api/users")
async def users(req, res):
return res({"users": []})
Active record models, zero config
class User(ORM):
id = IntegerField(primary_key=True)
name = StringField()
JWT tokens built-in
token = Auth.get_token({"user_id": 1})
valid = Auth.valid_token(token)
Background jobs, no Redis needed
queue = Queue(topic="emails")
queue.produce("emails", {"to": "a@b.com"})
Twig templates with auto-reload
@template("dashboard.twig")
@get("/dashboard")
async def dash(req, res):
return {"title": "Home"}
Multi-engine, one API
db = Database("sqlite:///app.db")
result = db.fetch("SELECT * FROM users")
for row in result: print(row["name"])
Rich debug page with source code
user = {"name": "Alice"}
role = user["role"] # KeyError!