Skip to main content

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

PyPI Version Python Versions License Code Style: Black Build

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.py becomes the endpoint /hello.
  • A file named routes/index.py becomes the root endpoint /.
  • Nested directories become nested paths. routes/api/v1/status.py becomes /api/v1/status.
  • Dynamic paths are created using square brackets in the filename. routes/users/[id].py becomes 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()

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

  1. Navigate to the project root.
  2. Run the application:
    python examples/app.py
    
  3. Test the routes in your browser or with curl:
    • curl http://127.0.0.1:8000/
    • curl http://127.0.0.1:8000/hello
    • curl 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

  1. Stabilize and Enhance the Router: Improve the routing system and its features.
  2. Request/Response Objects: Implement robust Request and Response objects.
  3. Middleware: Add support for middleware.
  4. CLI: Create a simple CLI for project scaffolding.
  5. Dependency Injection: Explore a simple DI system.

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

ushka-0.0.3.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ushka-0.0.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file ushka-0.0.3.tar.gz.

File metadata

  • Download URL: ushka-0.0.3.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ushka-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f7798dbd2433dfb9311d29f94c3afc0f43b9362eebd91142b21eb8250c7acf8d
MD5 e6707498c302c988455b4e3f06125a45
BLAKE2b-256 dfbfff8a724af26ba46a4798327ed044027d5765019b37ba4c1e25c3b2f2601e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ushka-0.0.3.tar.gz:

Publisher: python-publish.yml on kleber-code/ushka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ushka-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ushka-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ushka-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61045bc1bee8261e5af45ed2f68767288691eb038f8c5a80ff57e3cf693ab6a7
MD5 ac436959726934aba48495e43cde1c4f
BLAKE2b-256 914db3f6674aa59588910e761a9d8e0f71d11d0a30562431c6d8e0be741be95c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ushka-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on kleber-code/ushka

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