Creatine
A lightweight Python web framework with WSGI and ASGI support.
Installation
pip install creatine
For development:
pip install creatine[dev]
Quick Start
from creatine import Creatine
app = Creatine()
@app.route("/")
def home(req, resp):
resp.text = "Hello, World!"
@app.route("/greeting/{name}")
def greeting(req, resp, name):
resp.text = f"Hello, {name}"
@app.route("/book")
class BookResource:
def get(self, req, resp):
resp.text = "Books Page"
def post(self, req, resp):
resp.text = "Book created"
@app.route("/json")
def json_handler(req, resp):
resp.json = {"message": "hello"}
@app.route("/template")
def template_handler(req, resp):
resp.html = app.template("index.html", context={"title": "Hello"})
Running the Server
# Built-in dev server
creatine runserver app:app
# With Gunicorn (WSGI)
gunicorn app:app
# With Uvicorn (ASGI)
uvicorn app:asgi_app
ASGI & Async Handlers
Creatine supports both sync and async handlers when running under ASGI:
app = Creatine()
asgi_app = app.as_asgi()
@app.route("/async")
async def async_handler(req, resp):
resp.json = {"async": True}
Middleware
from creatine import Middleware
from creatine.log import LoggingMiddleware
# Built-in request logging
app.add_middleware(LoggingMiddleware)
# Custom middleware
class AuthMiddleware(Middleware):
def process_request(self, req):
print(f"Auth check: {req.url}")
def process_response(self, req, resp):
print(f"Completed: {resp.status_code}")
app.add_middleware(AuthMiddleware)
ORM
Built-in SQLite ORM for simple data persistence:
from creatine import Database, Table, Column, ForeignKey
db = Database("./app.db")
class Author(Table):
name = Column(str)
age = Column(int)
class Book(Table):
title = Column(str)
author = ForeignKey(Author)
db.create(Author)
db.create(Book)
author = Author(name="Jane", age=30)
db.save(author)
db.update(author)
db.delete(Author, id=1)
Features
- WSGI and ASGI compatible
- Async handler support
- Parameterized and basic routing
- Class-based and function-based handlers
- Built-in SQLite ORM with foreign keys
- Jinja2 templates
- Static files via WhiteNoise
- Middleware pipeline with built-in logging
- Custom exception handlers
- Test client (based on Requests)
- CLI (
creatine runserver) - GitHub Actions CI with pytest and mypy
Tests
pytest
Project Structure
creatine/
├── __init__.py # Package exports and version
├── __main__.py # CLI entry point
├── api.py # Core Creatine application class
├── asgi.py # ASGI adapter
├── exceptions.py # HTTPError
├── log.py # Logging middleware
├── middleware.py # Middleware base class
├── orm.py # SQLite ORM
├── response.py # Response wrapper
├── route.py # Route matching and dispatch
└── utils.py # Static file and test helpers
License
MIT
Metadata
Release files for creatine 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| creatine-0.1.0.tar.gz | 18.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| creatine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.6 kB
Release files / creatine-0.1.0.tar.gz
| Download URL | creatine-0.1.0.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39b14630ba65f1eb4565208625f5f4596b567bf4de33c496faf44067703d408d
|
|
BLAKE2b-256 checksum How to use checksums |
6872b7feb5368492b4886426a0fec53a5c78f31c99cd767bfbcd82f5c0acee40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / creatine-0.1.0-py3-none-any.whl
| Download URL | creatine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01c11e391dae620642db9e288ebdaf857a0f875cd1cd474562c0cacb5911caee
|
|
BLAKE2b-256 checksum How to use checksums |
a268fb52c59655793ffba9d487f881907662759e0f50b16ee200d4afbc6eba2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for creatine 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.