A minimalist Python web framework with minimal external dependencies.
Project description
Asok is a cohesive, full-stack Python web framework designed for developer speed, elegant architecture, and security-conscious defaults. Built around a "zero-runtime-dependency" philosophy, it unifies server-side logic and client-side reactivity into a single, high-performance package, offering a streamlined development experience from the first line of code.
๐ Official Website & Documentation | ๐ Quick Start Guide | ๐ฌ Join Discord | ๐ฅ YouTube Tutorials
๐ฏ Why Asok?
Zero Runtime Dependencies, Maximum Power
Asok requires no external runtime dependencies - just Python 3.10+. No Werkzeug, no Jinja2, no SQLAlchemy. The core framework is built from the Python standard library, making it:
- โ Extremely lightweight (~360KB)
- โ Easy to audit (everything in one codebase, no hidden dependencies)
- โ Forever stable (no dependency hell or supply chain risks)
Modern Developer Experience
# File-based routing like Next.js
src/pages/blog/[slug]/page.py โ /blog/hello-world
# Client-side Reactivity
<div asok-state="{ count: 0 }">
<button asok-on:click="count++" asok-text="count"></button>
</div>
# WebSocket Sync
class Counter(Component):
count = 0
@exposed
def increment(self):
self.count += 1
def render(self):
return self.html("counter.html")
# Admin interface in 2 lines
admin = Admin(app)
โจ Key Features
Core Framework
- ๐ Full Type Hints - Complete PEP 484 support for IDE autocomplete
- โจ๏ธ Powerful CLI - Scaffolding, migrations, dev server, production builds
- ๐ฃ๏ธ File-based Routing - Next.js-style routing (
src/pages/โ URLs) - โ๏ธ Dynamic Routes - Parameters via
[id],[slug:slug]patterns
Database & ORM
- ๐๏ธ Built-in ORM - SQLite (default), PostgreSQL, and MySQL support with relations, migrations, soft deletes
- ๐ Full-Text Search - FTS5/FULLTEXT integration for lightning-fast search
- ๐ Auto Password Hashing - PBKDF2-SHA256 with 600,000 iterations
- ๐ Query Builder - Fluent API with eager loading
Templates & Frontend
- ๐จ Template Engine - Jinja-compatible with inheritance and macros
- โก Reactive Components - Client-side reactivity (< 3KB, no build step)
- ๐ Live Components - Server-driven real-time updates via WebSockets
- ๐จ HTML Streaming - Chunked responses for instant TTFB
- ๐ญ Transitions - Built-in fade/slide/scale animations
High-Performance APIs
- ๐ Native API Engine - Build robust REST APIs with minimal code
- ๐ Auto-OpenAPI - Automatic OpenAPI 3.0 (Swagger) generation for every route
- ๐ก๏ธ Bearer Token Auth - Built-in secure authentication for stateless clients
- โก Optimized JSON - High-speed serialization for high-throughput services
- ๐ Live Documentation - Interactive API explorer (Swagger UI) included
Security
- ๐ CSRF Protection - Auto-rotation, HMAC validation, SameSite=Strict
- ๐ XSS Prevention - Auto-escaping templates, CSP nonces
- ๐ SQL Injection - Parameterized queries, column validation
- ๐ Secure Sessions - HttpOnly, Secure flags, HMAC-signed
- ๐ Path Traversal - Absolute path validation
- ๐ OWASP Top 10 - Built-in protections for common web vulnerabilities
Admin & Developer Tools
- ๐จโ๐ผ Auto Admin - Django-inspired admin in 2 lines of code
- ๐ i18n Ready - Multi-language support with JSON translations
- ๐ง Email Service - SMTP integration with templates
- ๐ฆ Production Build - Bytecode compilation, minification, WebP conversion
- ๐งช Testing Tools - Built-in test client, fixtures support
๐ญ Philosophy
Asok is designed for developers who want to build modern web applications without managing a complex stack of dependencies. It's a cohesive toolkit where everything works together out of the boxโfrom database to real-time featuresโwhile remaining simple enough to understand and audit.
Core Principles:
- Cohesion over Composition: All components are designed to work together seamlessly
- Simplicity over Magic: Clear, readable code with minimal abstraction layers
- Security by Default: Strong security defaults are built in, with additional production hardening available through configuration
- Developer Joy: Fast feedback loops, intuitive APIs, excellent error messages
Asok doesn't aim to replace existing frameworksโit offers a different approach for teams who value simplicity, security, and rapid development in a unified environment.
๐ ๏ธ Installation & Setup
1. Installation
By default, Asok has zero external dependencies and works out of the box with SQLite:
pip install asok
If you wish to use optional database engines or the Redis backend (for caching and sessions), install the corresponding extra(s):
# Optional database engines & capabilities
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 extras (e.g. Postgres + Redis)
pip install "asok[postgres-binary,redis]"
or clone the repo and use the asok/ folder.
2. Create a project
asok create my-project
cd my-project
3. Start the server
asok dev
๐๏ธ Project Structure
โโโ src
โย ย โโโ components # Reactive components
โย ย โโโ locales # JSON translations (en.json, fr.json, ...)
โย ย โย ย โโโ en.json
โย ย โย ย โโโ fr.json
โย ย โโโ middlewares # Request interceptors
โย ย โโโ models # ORM models (Post.py, User.py)
โย ย โโโ pages # YOUR ROUTES (page.py, page.html)
โย ย โย ย โโโ page.html
โย ย โย ย โโโ page.py
โย ย โโโ partials # css, js, images, html, uploads
โย ย โโโ css
โย ย โย ย โโโ base.css
โย ย โโโ html
โย ย โย ย โโโ base.html
โย ย โโโ images
โย ย โย ย โโโ logo.svg
โย ย โโโ js
โย ย โย ย โโโ base.js
โย ย โโโ uploads
โโโ wsgi.py # Application entry point
๐ฃ๏ธ Routing
Routing is dictated by the structure of the src/pages/ folder. Each folder represents a URL segment, and contains a page.py or page.html file.
src/pages/page.htmlโ/src/pages/about/page.htmlโ/aboutsrc/pages/user/[id]/page.pyโ/user/123(idparameter)src/pages/blog/[slug:slug]/page.pyโ/blog/my-post-slug
Dynamic Page Example (src/pages/shop/[cat]/page.py)
from asok import Request
def render(request: Request):
category = request.params.get('cat')
return f"Shop : {category}"
๐จ Templates & Inheritance
Templates in src/pages/ can inherit from layouts in src/partials/html/.
Layout (src/partials/html/base.html) :
<!DOCTYPE html>
<html lang="{{ request.lang }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="{{ static('images/logo.svg') }}" type="image/svg+xml">
<title>{% block title %}{% endblock %} — my-project</title>
<link rel="stylesheet" href="{{ static('css/base.css') }}">
<script defer src="{{ static('js/base.js') }}"></script>
</head>
<body>
<main>{% block main %}{% endblock %}</main>
</body>
</html>
Page (src/pages/page.html) :
{% extends "html/base.html" %}
{% block title %}Welcome{% endblock %}
{% block main %}
<div class="container">
<img src="{{ static('images/logo.svg') }}" alt="Logo Asok">
<h1>Welcome to Asok</h1>
<p>No dependenciesโjust Pythonโs standard library</p>
<p>Edit <code>src/pages/page.html</code> to get started.</p>
</div>
{% endblock %}
๐๏ธ AsokDB (The ORM)
Define your models in src/models/.
from asok import Field, Model
class User(Model):
email = Field.String(unique=True, nullable=False)
password = Field.Password()
name = Field.String()
is_admin = Field.Boolean(default=False)
created_at = Field.CreatedAt()
๐ i18n & Validation
- Translation:
{{ __('welcome') }}(looks insrc/locales/). - Validation:
Validator(data).rule('email', 'required|email'). - CSRF:
{{ request.csrf_input() }}automatic in forms.
๐จ Admin Customization
The administration interface is highly customizable:
admin = Admin(app, site_name="My Platform", favicon="images/logo.svg")
Asset Resolution (Smart Resolution)
The admin automatically detects the source of resources:
- Internal Assets: Files like
admin.cssor the defaultlogo.svgare served from the package. - Project Assets: If you specify a path (e.g.
images/logo.svgoruploads/icon.png), the admin will serve them from your resources folder (src/partials/).
๐ Towards Production
Asok supports both WSGI and ASGI. Use Gunicorn for WSGI or Uvicorn for ASGI:
# WSGI (Gunicorn)
gunicorn wsgi:app
# ASGI (Uvicorn) โ for async/await support
uvicorn asgi:app
๐ Production Security Checklist
Asok is built to be secure by default, but production environments require specific configurations to enable all protections.
1. Mandatory Environment Variables
In production (DEBUG=False), Asok enforces strict security checks:
SECRET_KEY: Must be at least 32 characters long. Usesecrets.token_hex(32)to generate one.APP_URL: Required for Magic Links to prevent Host Header Injection. Example:https://myapp.com.
2. Secure Defaults
- DEBUG: Default is
False. You must explicitly setDEBUG=Truein your.envfor development. - Password Hashing: PBKDF2-SHA256 with 600,000 iterations.
- Security Headers: HSTS (1 year), CSP (with nonces), X-Frame-Options (DENY), and X-Content-Type-Options (nosniff) are enabled by default.
3. Recommended .env for Production
ASOK_ENV=production
DEBUG=false
SECRET_KEY=your-64-character-ultra-secure-key-here
APP_URL=https://yourdomain.com
DATABASE_URL=sqlite:///data/prod.db
๐ค Contributing
We โค๏ธ contributions! Asok is built to be simple, transparent, and fun to hack on. Whether you're a Python beginner or expert, there's a place for you here.
๐ Ways to Contribute
- ๐ Report bugs - Found an issue? Open a bug report
- ๐ก Suggest features - Have an idea? Start a discussion
- ๐ Improve docs - Spot a typo? Docs are in asok-docs
- ๐ง Submit PRs - Fixed something? Send a pull request
- โญ Star the repo - Show your support!
- ๐ฌ Help others - Answer questions in Discussions
๐ Quick Start for Contributors
# 1. Fork and clone the repo
git clone https://github.com/YOUR_USERNAME/asok.git
cd asok
# 2. Create a virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# 3. Install dependencies (dev mode)
pip install -e .
# 4. Run the test suite
python -m pytest
# 5. Create a branch for your feature
git checkout -b feature/amazing-feature
# 6. Make your changes and test
python -m pytest -v
# 7. Commit and push
git commit -m "feat: add amazing feature"
git push origin feature/amazing-feature
๐ Read our full Contributing Guide for code style, commit conventions, and more.
๐ Contributors
Thanks to all our amazing contributors! ๐
๐ฌ Support & Resources
Need help?
- ๐ Read the documentation
- ๐ Search existing issues
- ๐ฌ Ask in GitHub Discussions
- ๐ Report bugs via GitHub Issues
Documentation & Resources:
- ๐ Complete Framework Guide
- ๐ Documentation Source - Contribute to the docs
- ๐ ๏ธ Code Examples - Ready-to-use projects and templates
- ๐ CHANGELOG - See what's new in each release
Stay updated:
- โญ Star the repo to follow development
- ๐ Watch releases for new versions
๐บ๏ธ Roadmap
Asok is actively developed with exciting features planned:
v0.4.0 - GraphQL & Extensions โ Released June 2026
- Plugin System: Fully extensible community extension system with secure path sandboxing
- Advanced SSR & Hydration: Islands architecture, Static Site Generation (SSG), and Incremental Static Regeneration (ISR)
- GraphQL API: Built-in GraphQL server with schema auto-generation from models and subscription support
- API Versioning: URL-based and header-based versioning, negotiation, deprecation warnings and sunsetting
- Advanced WebSockets: Real-time presence tracking, room authorization hooks, Direct Messages, and typing indicators
- Multi-Database Scaling: Advanced ORM database router for read replicas and query load balancing
v0.3.0 - Enterprise Ready โ Released June 2026
- Async/ASGI: Full async/await support with ASGI/WSGI dual engine
- Multi-DB: PostgreSQL & MySQL with connection pooling, vector search
- Advanced ORM: Polymorphic relations, self-referencing, nested eager loading, N+1 detection
- WebSocket Rooms: Multi-user collaboration with room broadcasting
- Redis: Caching, sessions, cache warming, fragment caching
- Cloud: AWS S3 storage integration
- Background Jobs:
asok workerfor async task processing - Admin Enhancements: Inline editing, advanced filtering, saved presets, column customization
- VSCode Extension: Syntax highlighting, IntelliSense, snippets, route navigation
- Localization: Translation management UI and automatic string extraction
- Query Optimization: N+1 detection, query analysis, index suggestions, slow query logging
v0.5.0 - Enterprise Scale & Observability (Planned Q1 2027)
- Built-in Monitoring: Prometheus/Grafana integration, performance metrics and health check endpoints
- Multi-Tenancy: SaaS tenant isolation structures and middleware
- CDN Integration: Automatic static media asset pipeline delivery
- Microservices Support: Built-in gRPC support and service mesh integration
Note: Timelines are subject to change based on community feedback and development priorities.
๐ญ Production Status
Asok v0.4.0 is actively developed software with growing production adoption. It's suitable for:
โ Recommended for:
- Production web applications and APIs
- Internal tools and admin dashboards
- Personal projects and MVPs
- Rapid prototyping and experimentation
- Learning full-stack Python development
- Projects requiring zero runtime dependencies
- Applications where dependency auditing is critical
โ ๏ธ Current Limitations:
- Ecosystem: Growing community, limited third-party plugins
- Maturity: v0.4.x - APIs are stabilizing but may evolve before v1.0
For mission-critical production applications, Asok v0.4.0 provides enterprise features (async, multi-DB, Redis, S3) suitable for production workloads. Evaluate if the current feature set meets your specific requirements.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asok-0.4.0.tar.gz.
File metadata
- Download URL: asok-0.4.0.tar.gz
- Upload date:
- Size: 439.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b040ec5a44c8baeabb0e65ca34b748faebfc21db094350be2c76d21c2ac620
|
|
| MD5 |
45b4260f8447e9f79130af90c60b11dd
|
|
| BLAKE2b-256 |
dfd678f57dd1bf70f2bb4256dba906921a7fde219a6412ae4f778cfe8f76ae19
|
Provenance
The following attestation bundles were made for asok-0.4.0.tar.gz:
Publisher:
release.yml on asok-framework/asok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asok-0.4.0.tar.gz -
Subject digest:
a4b040ec5a44c8baeabb0e65ca34b748faebfc21db094350be2c76d21c2ac620 - Sigstore transparency entry: 1748721390
- Sigstore integration time:
-
Permalink:
asok-framework/asok@e7bf783f497a82113a70347970064569777ca08d -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/asok-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e7bf783f497a82113a70347970064569777ca08d -
Trigger Event:
release
-
Statement type:
File details
Details for the file asok-0.4.0-py3-none-any.whl.
File metadata
- Download URL: asok-0.4.0-py3-none-any.whl
- Upload date:
- Size: 503.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4baa4788a0de7356230a68b2689e3a81453bdd5103b2dba08bfa9c8b074a639
|
|
| MD5 |
774bbcfa756bef53047ed36f210fe41d
|
|
| BLAKE2b-256 |
b44b49890636bfcc139478f04272f4917a66748ca46fcc853d32d67bfa410db8
|
Provenance
The following attestation bundles were made for asok-0.4.0-py3-none-any.whl:
Publisher:
release.yml on asok-framework/asok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asok-0.4.0-py3-none-any.whl -
Subject digest:
c4baa4788a0de7356230a68b2689e3a81453bdd5103b2dba08bfa9c8b074a639 - Sigstore transparency entry: 1748721609
- Sigstore integration time:
-
Permalink:
asok-framework/asok@e7bf783f497a82113a70347970064569777ca08d -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/asok-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e7bf783f497a82113a70347970064569777ca08d -
Trigger Event:
release
-
Statement type: