Skip to main content

A minimalist, zero-dependency Python web framework.

Project description

Asok Framework Logo

GitHub Stars License PyPI Version Python Version Tests Issues Pull Requests


Asok is a powerful and elegant "zero-dependency" Python web framework that brings modern development patterns to Python. Built with security-first principles, it combines the simplicity of Flask with the batteries-included approach of Django, while introducing Next.js-style file-based routing.

๐ŸŒ Official Website & Documentation | ๐Ÿ“– Quick Start Guide | ๐Ÿ’ฌ Join Discord | ๐ŸŽฅ YouTube Tutorials


๐ŸŽฏ Why Asok?

Zero Dependencies, Maximum Power

Unlike other Python frameworks, Asok requires zero external dependencies - just Python 3.10+. No Werkzeug, no Jinja2, no SQLAlchemy. Everything is built from the Python standard library, making it:

  • โœ… Extremely lightweight (~200KB)
  • โœ… Dead simple to audit (security teams love it)
  • โœ… Forever stable (no dependency hell)
  • โœ… Fast to install (< 1 second)

Modern Developer Experience

# File-based routing like Next.js
src/pages/blog/[slug]/page.py  โ†’  /blog/hello-world

# Reactive components out of the box
<div asok-state="{ count: 0 }">
  <button asok-on:click="count++">{{ count }}</button>
</div>

# Admin interface in 2 lines
admin = Admin(app)

Production-Ready Security

  • ๐Ÿ”’ OWASP Top 10 protections built-in
  • ๐Ÿ”’ Automatic CSRF tokens with rotation
  • ๐Ÿ”’ SQL injection prevention via parameterized queries
  • ๐Ÿ”’ XSS protection with auto-escaping templates
  • ๐Ÿ”’ Secure sessions (HttpOnly, SameSite=Strict, HMAC-signed)
  • ๐Ÿ”’ 10/10 security score in comprehensive audits

โœจ Key Features

Core Framework

  • ๐Ÿš€ Zero Dependencies - Pure Python stdlib, no external packages
  • ๐Ÿ’Ž Full Type Hints - Complete PEP 484 support for IDE autocomplete
  • ๐Ÿ“ฆ Tiny Footprint - ~200KB, installs in < 1 second
  • โŒจ๏ธ 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 with relations, migrations, soft deletes
  • ๐Ÿ” Full-Text Search - FTS5 integration for lightning-fast search
  • ๐Ÿ” Auto Password Hashing - PBKDF2-SHA256 with 100k 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

Security (10/10 Score)

  • ๐Ÿ”’ 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

Admin & Developer Tools

  • ๐Ÿ‘จโ€๐Ÿ’ผ Auto Admin - Django-style 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

โš–๏ธ Asok vs Django vs Flask

Asok was designed to bring the best of both worlds (the lightweight nature of Flask and the batteries-included approach of Django), while adding modern file-based routing (inspired by Next.js/SvelteKit).

Feature Asok Flask Django
External Dependencies 0 (Zero) ~6 (Werkzeug, Jinja...) ~3 (asgiref, sqlparse...)
Philosophy Batteries Included + Modern Micro-framework Megalo-framework
Routing System File-based (src/pages/) Decorators (@app.route) Centralized (urls.py)
Built-in ORM Yes (AsokDB - optimized SQLite) No (SQLAlchemy required) Yes (Full-featured, multi-DB)
Generated Admin Yes, 100% automatic and reactive No (Flask-Admin required) Yes, historical and heavy
Real-time (WebSockets) Native (Alive Engine) No (Flask-SocketIO required) Complex (Django Channels)
Reactive Components Native (Live Components) No No
Ideal for Fast projects, Modern SaaS, Zero devops Simple APIs, Microservices Large legacy architectures

๐Ÿ› ๏ธ Installation & Setup

1. Installation

You can install Asok via pip:

pip install asok

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 โ†’ /about
  • src/pages/user/[id]/page.py โ†’ /user/123 (id parameter)
  • 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 %} &mdash; 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 in src/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.css or the default logo.svg are served from the package.
  • Project Assets: If you specify a path (e.g. images/logo.svg or uploads/icon.png), the admin will serve them from your resources folder (src/partials/).

๐Ÿš€ Towards Production

Asok is WSGI compatible. You can use Gunicorn or any other WSGI server:

gunicorn wsgi:app

๐Ÿค 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

๐Ÿš€ 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 (353 tests should pass!)
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! ๐ŸŽ‰


๐ŸŒ Ecosystem

Explore the Asok ecosystem:

  • ๐Ÿ› ๏ธ Asok Examples - Ready-to-use projects and templates
  • ๐Ÿงช Asok Lab - Experimental features, benchmarks, playground
  • ๐Ÿ“– Asok Docs - Documentation and website source
  • ๐ŸŽ“ Asok Tutorials - Step-by-step learning paths

๐Ÿ’ฌ Community & Support

Join our growing community:

Need help?


๐Ÿ—บ๏ธ Roadmap

Asok is actively developed with exciting features planned:

v0.2.0 (Q2 2026) - Enterprise Features

  • PostgreSQL & MySQL support, advanced ORM relationships
  • WebSocket rooms for real-time collaboration
  • Background job queue system
  • Plugin ecosystem & CLI enhancements

v0.3.0 (Q3 2026) - Modern Stack

  • GraphQL API support with auto-generated schemas
  • Server-side rendering (SSR) & static site generation
  • Built-in monitoring & observability tools
  • Full async/await support (ASGI)

See the detailed roadmap for complete feature lists, timelines, and how to contribute to planning.


โญ Star History

Star History Chart


๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asok-0.1.3.tar.gz (339.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asok-0.1.3-py3-none-any.whl (321.3 kB view details)

Uploaded Python 3

File details

Details for the file asok-0.1.3.tar.gz.

File metadata

  • Download URL: asok-0.1.3.tar.gz
  • Upload date:
  • Size: 339.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asok-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7930e4b43c257cd61e835dbbaf66ff0916dd3174399c13929370c326d91c3bf9
MD5 3ef10eb6c7d4ced6e017f7c7c12a24f0
BLAKE2b-256 4cea98b7ddffd8f40c82f60d2f6a2287362e662a3fef9980693766c27d1dc89e

See more details on using hashes here.

Provenance

The following attestation bundles were made for asok-0.1.3.tar.gz:

Publisher: release.yml on asok-framework/asok

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asok-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: asok-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 321.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asok-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 74e620c72c64e4cd256d54ba4447edb1fb2bd4964ca7ee1cd4b0105b9d42a0f1
MD5 b5634e79386ea82640fd19374ade0107
BLAKE2b-256 88e3bcb0c625b5a3c3cea468b853b482ddbe290917a18f9942f5d1f9cf69ae24

See more details on using hashes here.

Provenance

The following attestation bundles were made for asok-0.1.3-py3-none-any.whl:

Publisher: release.yml on asok-framework/asok

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page