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.2.tar.gz (300.1 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.2-py3-none-any.whl (297.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asok-0.1.2.tar.gz
  • Upload date:
  • Size: 300.1 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.2.tar.gz
Algorithm Hash digest
SHA256 4b954f3ce5a136dab85b3bda23c79e2cefb2c6137ca66409dc5f299e49c94e2b
MD5 a047247dc8ffe3cdc9e39b578d6d43dd
BLAKE2b-256 225a2d2ff7533f23abce78d079187f59f8e2f048e74ad1086b2a175f693c6f24

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asok-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 297.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39046dcd76a625da83d067ea5b7148fd4bd27b1a367ecedb5607dc6ae5621ae8
MD5 653a2b0be323d51a690bfe54370c4d2f
BLAKE2b-256 a7690837aa86d5fd740c00994e872ce1ab5735a3ec72e40af43d3dd42027f2cc

See more details on using hashes here.

Provenance

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