Ushka is a minimal, experimental Python micro-framework for hobbyists and solo developers. Its goal is to enable rapid API development with **zero boilerplate** by using file-based routing.
Project description
Ushka
Ushka is a minimal, experimental Python ASGI web framework based on file-based routing.
⚠️ Alpha Stage: Not Production Ready
This is an early alpha release. The project is in active, unstable development. The API may change at any time.
Core Concept: File-Based Routing
The filesystem is the API. Ushka scans a routes/ directory and maps the file and directory structure directly to URL paths.
- A file like
routes/hello.pybecomes the endpoint/hello. - A file named
routes/index.pybecomes the root endpoint/. - Nested directories become nested paths.
routes/api/v1/status.pybecomes/api/v1/status. - Dynamic paths are created using square brackets in the filename.
routes/users/[id].pybecomes the endpoint/users/[id]. - The HTTP method is determined by the function name inside the file (e.g.,
get(),post()).
Example
This example uses autodiscovery to create a simple API.
Project Structure
examples/
├── app.py
└── routes/
├── hello.py
├── index.py
└── hello/
└── [name].py
1. The Route Handlers (examples/routes/)
These files contain the functions that will handle requests.
examples/routes/index.py (handles GET /)
def get():
return "Welcome to the autodiscovered example!"
examples/routes/hello.py (handles GET /hello)
def get():
return "Hello, World!"
examples/routes/hello/[name].py (handles GET /hello/[name])
def get(name: str):
return f"Hello, {name}!"
2. The Main Application (examples/app.py)
This file creates the Ushka application and tells it to automatically discover the routes.
from ushka import Ushka
from pathlib import Path
app = Ushka()
# Autodiscover routes from the 'routes' directory
routes_path = Path(__file__).parent.joinpath("routes")
app.router.autodiscover(base_path=routes_path)
if __name__ == "__main__":
print("Starting Ushka server on http://127.0.0.1:8000")
app.run("127.0.0.1", 8000)
How to Run the Example
- Navigate to the project root.
- Run the application:
python examples/app.py - Test the routes in your browser or with
curl:curl http://127.0.0.1:8000/curl http://127.0.0.1:8000/hellocurl http://127.0.0.1:8000/hello/Developer
Manual Routing
For more complex scenarios, you can add routes manually. This is useful if you prefer not to use file-based routing.
from ushka import Ushka
app = Ushka()
def my_handler():
return "This was added manually."
app.router.add_route("GET", "/manual", my_handler)
Roadmap
- Stabilize and Enhance the Router: Improve the routing system and its features.
- Request/Response Objects: Implement robust
RequestandResponseobjects. - Middleware: Add support for middleware.
- CLI: Create a simple CLI for project scaffolding.
- Dependency Injection: Explore a simple DI system.
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 ushka-0.0.2.tar.gz.
File metadata
- Download URL: ushka-0.0.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fb60a4d4c4e5ef3d8e4abd6ca5674d705ee13c828844918b10f55fb521d67f6
|
|
| MD5 |
35be46833736ac8b169942ddbae45314
|
|
| BLAKE2b-256 |
8d91af38f80bc80480f8fe14f000c4f70918dbefc3bdef88e2eb5579e43daf0a
|
Provenance
The following attestation bundles were made for ushka-0.0.2.tar.gz:
Publisher:
python-publish.yml on kleber-code/ushka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ushka-0.0.2.tar.gz -
Subject digest:
4fb60a4d4c4e5ef3d8e4abd6ca5674d705ee13c828844918b10f55fb521d67f6 - Sigstore transparency entry: 702159368
- Sigstore integration time:
-
Permalink:
kleber-code/ushka@185db327f8f6a6fb4c760312778412cda8014f82 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/kleber-code
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@185db327f8f6a6fb4c760312778412cda8014f82 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ushka-0.0.2-py3-none-any.whl.
File metadata
- Download URL: ushka-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e608518498d8f95a7a75c01de627d161f5a6491fb5efc70254566ae93f34d60
|
|
| MD5 |
dfc849f5081ea2cf684a8da08bbaa53e
|
|
| BLAKE2b-256 |
2eddc638b9c4ce8000da20df476cca8f1b8ed3e668909e7d6e4a612cfe49af37
|
Provenance
The following attestation bundles were made for ushka-0.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on kleber-code/ushka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ushka-0.0.2-py3-none-any.whl -
Subject digest:
5e608518498d8f95a7a75c01de627d161f5a6491fb5efc70254566ae93f34d60 - Sigstore transparency entry: 702159373
- Sigstore integration time:
-
Permalink:
kleber-code/ushka@185db327f8f6a6fb4c760312778412cda8014f82 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/kleber-code
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@185db327f8f6a6fb4c760312778412cda8014f82 -
Trigger Event:
push
-
Statement type: