Getting StartedΒΆ
Keywords: installation, setup, create project, CLI, folder structure, interactive CLI, dev server, running locally, sqlite
Asok is a zero-dependency Python framework designed for speed, security, and a unified development experience through intuitive file-based routing and native client-side reactivity.
InstallationΒΆ
By default, Asok has zero external dependencies and works out of the box with SQLite.
# Default installation (SQLite, zero dependencies)
pip install asok
# Optional backends & capabilities (PostgreSQL, MySQL, Redis, Async)
pip install "asok[postgres]" # Standard (requires system libpq)
pip install "asok[postgres-binary]" # Binarized (no system dependencies, great for dev)
pip install "asok[mysql]"
pip install "asok[redis]"
pip install "asok[async]"
# Combined optional extras (e.g. Postgres + Redis)
pip install "asok[postgres-binary,redis]"
π‘ Note for VS Code Users: For the best developer experience, we highly recommend installing the official Asok VS Code Extension. It provides native autocompletion, reactive snippets, and integrated CLI commands directly in your editor.
Create a projectΒΆ
Asok features a smart interactive CLI. Just run the create command and it will guide you through the setup:
asok create myapp
# ? Add Tailwind CSS support? [y/N]: y
# ? Add Admin interface? [y/N]: y
# ? Add Image Optimization (WebP)? [y/N]: y
If you prefer to skip questions, use flags: asok create myapp --tailwind --admin --image.
Run the server:
asok dev
Open http://127.0.0.1:8000 β your app is running with live browser reload. Edit any file and the browser refreshes automatically.
Want a different port? Use asok dev -p 3000. If the port is busy, Asok finds the next free one automatically.
Project structureΒΆ
myapp/
βββ .env # Environment variables
βββ src
βΒ Β βββ components # Reactive (Live) Components
βΒ Β βββ locales # Translation files (en.json, fr.json)
βΒ Β βΒ Β βββ en.json
βΒ Β βΒ Β βββ fr.json
βΒ Β βββ middlewares # Middleware handlers
βΒ Β βββ models # Database models
βΒ Β βΒ Β βββ user.py
βΒ Β βββ pages # Routes (file-based)
βΒ Β βΒ Β βββ page.html (or .asok)
βΒ Β βΒ Β βββ page.py
βΒ Β βββ partials # Shared assets
βΒ Β βββ css
βΒ Β βΒ Β βββ base.css
βΒ Β βββ html
βΒ Β βΒ Β βββ base.html
βΒ Β βββ images
βΒ Β βΒ Β βββ logo.svg
βΒ Β βββ js
βΒ Β βΒ Β βββ base.js
βΒ Β βββ uploads
βββ wsgi.py # Entry point
How it worksΒΆ
A request arrives at
/contactAsok looks for
src/pages/contact/page.py(orpage.html/page.asok)It calls the
render(request)functionYour function returns HTML via
request.html('page.html')Asok sends the response
Thatβs it. No decorators, no app.route(), no configuration file. Your folder structure is your routing.
Minimal exampleΒΆ
# src/pages/page.py
from asok import Request
def render(request: Request):
return request.html('page.html')
<!-- src/pages/page.html -->
<h1>Hello, Asok!</h1>
ConfigurationΒΆ
All config goes in .env:
DEBUG=true
SECRET_KEY=change-me-in-production
Access in code:
request.env('SECRET_KEY')
request.env('DEBUG') # Returns True (auto-cast)
Whatβs included (zero dependencies)ΒΆ
Feature |
How |
|---|---|
Routing |
Folder-based, automatic |
Database |
SQLite ORM built-in (0 dependencies) |
Templates |
Built-in, high-performance engine |
Forms |
Declarative, auto-validated |
Auth |
Login/logout/sessions |
i18n |
JSON locale files |
SMTP via stdlib |
|
Cache |
Memory or file-based |
CSRF |
Automatic protection |
CLI |
Generators, migrations, seeder |
Testing |
WSGI test client |
Everything runs on the Python standard library by default. No pip install is needed beyond asok itself unless you opt-in to PostgreSQL, MySQL, or Redis backends.