Skip to main content

A minimalist, zero-dependency Python web framework.

Project description

Asok Framework Logo

GitHub Stars License PyPI Version Python Version


Asok is a powerful and elegant "zero-dependency" Python micro-framework. It introduces a professional modular architecture, file-based routing, and a comprehensive CLI tool designed for speed and simplicity.

🌐 Official Website & Documentation


✨ Key Features

  • 🚀 Zero Dependencies: Relies exclusively on the Python standard library.
  • 💎 Professional Typing: Full support for PEP 484 type hints for a robust developer experience.
  • 📦 Modular Package: Install via pip or by simply dropping the asok/ folder into your project.
  • ⌨️ Powerful CLI: Scaffolding (asok make), Dev Server (asok dev), and assets management.
  • 🌍 Local Geolocation: Built-in IP detection and localization without third-party APIs.
  • 🛣️ File-based Routing: Your src/pages/ directories define your URLs.
  • ⛓️ Dynamic Routing: Native support for parameters via [param].
  • 🔐 Built-in Auth: Secure sessions via signed cookies (HMAC).
  • 🗄️ AsokDB: A minimalist SQLite ORM with relationships and automatic hashing.
  • 🎨 Template Engine: Jinja-like syntax with inheritance (extends) and blocks.
  • Smart Streaming: Ultra-fast HTML streaming with on-the-fly asset injection.
  • 💾 Component Persistence: Reactive component state preserved across page navigations.

⚖️ 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

Contributions are more than welcome! Asok is built to be simple and transparent, making it a great codebase to dive into.

  • Found a bug? Open an Issue.
  • Have a feature idea? Start a Discussion.
  • Fixed something? Submit a Pull Request.

Make sure to run the tests and linter before submitting your PR:

make lint
make test

🌐 Ecosystem

Explore the Asok ecosystem:

  • 🛠️ Asok Examples: A collection of ready-to-use projects and templates.
  • 🧪 Asok Lab: Experimental features, benchmarks, and playground.
  • 📖 Asok Docs & Website Source: The source code for the documentation and the official website.

📜 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.1.tar.gz (291.3 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.1-py3-none-any.whl (291.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asok-0.1.1.tar.gz
  • Upload date:
  • Size: 291.3 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.1.tar.gz
Algorithm Hash digest
SHA256 a1b8f973ecfe7bcec98d6050b375da42c22c8e56d11edc161bd9e693ae1cc499
MD5 b048f30a5c3a49ccae5d224f62adb6b5
BLAKE2b-256 70d4ee5524d02ff62010cb398cf3ac25ee41c0e1c4fba770c9254d6f93825589

See more details on using hashes here.

Provenance

The following attestation bundles were made for asok-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: asok-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 291.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4cf1d3f52fb5eb751717e42d0f02f2c24ca46ecd342455fcd4ea589c3fef989
MD5 f487d695ef405379a396ea876c38499b
BLAKE2b-256 b519658426a3a83b1ee32e6ba9dcbaf51028967c3afa5299df3d3908f2221f7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for asok-0.1.1-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