A minimalist, zero-dependency Python web framework.
Project description
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
pipor by simply dropping theasok/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โ/aboutsrc/pages/user/[id]/page.pyโ/user/123(idparameter)
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 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 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.
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4795fedec8c4f08f21fcdf7d232b707a3a40a72795595c999a6a4811509a01a
|
|
| MD5 |
7b9955aacf58c35511087dc7fe76fd55
|
|
| BLAKE2b-256 |
37674a50ee7ce8e1ae0757ad00a95a6213b11d68239b92f4a54401965bf0a355
|
Provenance
The following attestation bundles were made for asok-0.1.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.1.0.tar.gz -
Subject digest:
b4795fedec8c4f08f21fcdf7d232b707a3a40a72795595c999a6a4811509a01a - Sigstore transparency entry: 1340898936
- Sigstore integration time:
-
Permalink:
asok-framework/asok@da5194bd988f61c0b0a9041132289120e1ea9e87 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/asok-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da5194bd988f61c0b0a9041132289120e1ea9e87 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9662ff854dae6e4d69c25a8b8e2bd76d1d807a8b8ea29fa404470e0b616dc7ba
|
|
| MD5 |
255f24b63bd435d7616933c31d7f0a9e
|
|
| BLAKE2b-256 |
34f9f6f181f2c9e4207bc6c8127992a8662099effaafff2fb982228b28d504bf
|
Provenance
The following attestation bundles were made for asok-0.1.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.1.0-py3-none-any.whl -
Subject digest:
9662ff854dae6e4d69c25a8b8e2bd76d1d807a8b8ea29fa404470e0b616dc7ba - Sigstore transparency entry: 1340898937
- Sigstore integration time:
-
Permalink:
asok-framework/asok@da5194bd988f61c0b0a9041132289120e1ea9e87 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/asok-framework
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da5194bd988f61c0b0a9041132289120e1ea9e87 -
Trigger Event:
release
-
Statement type: