Skip to main content

A minimalist, zero-dependency Python web framework.

Project description

Asok Framework Logo Asok Framework

Asok is a powerful and elegant "zero-dependency" Python micro-framework. Version 0.1.0 introduces a professional modular architecture, file-based routing through the src/pages/ directory, and a comprehensive CLI tool.

๐Ÿ“– โ†’ Full Documentation โ€” 44 chapters, from installation to production deployment.


โœจ 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.
  • CLI Tool: 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 Authentication: Secure sessions via signed cookies (HMAC).
  • AsokDB: A mini SQLite ORM with relationships and automatic hashing.
  • Template Engine: Jinja-like syntax with inheritance (extends) and blocks.

โš–๏ธ 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 (coming soon) 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

.
โ”œโ”€โ”€ wsgi.py            # Application entry point
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ locales/       # JSON translations (en.json, fr.json)
โ”‚   โ”œโ”€โ”€ middlewares/   # Request interceptors
โ”‚   โ”œโ”€โ”€ models/        # ORM models (Post.py, User.py)
โ”‚   โ”œโ”€โ”€ pages/         # YOUR ROUTES (page.py or page.html)
โ”‚   โ”‚   โ”œโ”€โ”€ page.html  # Route /
โ”‚   โ”‚   โ””โ”€โ”€ about/
โ”‚   โ”‚       โ””โ”€โ”€ page.html # Route /about
โ”‚   โ””โ”€โ”€ partials/      # Shared resources
โ”‚       โ”œโ”€โ”€ css/, js/, images/
โ”‚       โ””โ”€โ”€ html/      # Layouts and components

๐Ÿ›ฃ๏ธ 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)

Dynamic Page Example (src/pages/shop/[cat]/page.py)

def render(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/main.html) :

<html>
<body>
    {% include 'html/_nav.html' %}
    <main>{% block content %}{CONTENT}{% endblock %}</main>
</body>
</html>

Page (src/pages/page.html) :

{% extends 'html/main.html' %}
{% block content %}
    <h1>Welcome to Asok V2</h1>
{% endblock %}

๐Ÿ—„๏ธ AsokDB (The ORM)

Define your models in src/models/.

from asok import Model, Field, Relation

class User(Model):
    name = Field.String()
    email = Field.String(unique=True)
    password = Field.Password()
    posts = Relation.HasMany('Post')

๐ŸŒ 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

๐Ÿ“œ License

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



Asok Framework

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.0.tar.gz (286.5 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.0-py3-none-any.whl (287.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asok-0.1.0.tar.gz
  • Upload date:
  • Size: 286.5 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.0.tar.gz
Algorithm Hash digest
SHA256 b4795fedec8c4f08f21fcdf7d232b707a3a40a72795595c999a6a4811509a01a
MD5 7b9955aacf58c35511087dc7fe76fd55
BLAKE2b-256 37674a50ee7ce8e1ae0757ad00a95a6213b11d68239b92f4a54401965bf0a355

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asok-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 287.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9662ff854dae6e4d69c25a8b8e2bd76d1d807a8b8ea29fa404470e0b616dc7ba
MD5 255f24b63bd435d7616933c31d7f0a9e
BLAKE2b-256 34f9f6f181f2c9e4207bc6c8127992a8662099effaafff2fb982228b28d504bf

See more details on using hashes here.

Provenance

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