Skip to main content

Simple ASGI micro framework for Python

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Nebula

Simple ASGI micro framework for Python.

Installation

pip install project-nebula

Usage

from nebula import Nebula, JSONResponse, HTMLResponse

app = Nebula()


@app.get("/")
async def home(request):
    return HTMLResponse("<h1>Welcome to Nebula!</h1>")


@app.get("/api/hello")
async def hello(request):
    return JSONResponse({"message": "Hello, World!"})


@app.post("/api/echo")
async def echo(request):
    data = await request.json()
    return JSONResponse({"echo": data})


# Typed path parameters
@app.get("/api/users/{id:int}")
async def get_user(request):
    user_id = request.path_params["id"]  # int
    return JSONResponse({"id": user_id, "name": f"User {user_id}"})


@app.get("/api/items/{name:str}")
async def get_item(request):
    name = request.path_params["name"]  # str
    return JSONResponse({"name": name, "type": "item"})


@app.get("/api/score/{value:float}")
async def get_score(request):
    value = request.path_params["value"]  # float
    return JSONResponse({"score": value, "doubled": value * 2})


# Sync handler example
@app.get("/api/sync")
def sync_handler(request):
    return JSONResponse({"type": "sync", "message": "I'm synchronous!"})


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Run

python examples/app.py

Or with uvicorn directly:

uvicorn examples.app:app --reload

Features

  • ASGI compliant
  • JSON and HTML responses
  • Path parameters support (/users/{id})
  • Request body parsing (JSON, text)
  • Multiple HTTP methods (GET, POST, PUT, DELETE)

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

project_nebula-0.1.2.tar.gz (102.5 kB view details)

Uploaded Source

Built Distribution

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

project_nebula-0.1.2-cp312-cp312-win_amd64.whl (133.3 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

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

File metadata

  • Download URL: project_nebula-0.1.2.tar.gz
  • Upload date:
  • Size: 102.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for project_nebula-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2cbaaeaef8627044981028d3c20ef34bbc4f7d41a148f2c9a68d893c029011ef
MD5 d042fb8d1a69aeadf7f98a21df3064d7
BLAKE2b-256 f13cb040a90714e6092ec46cd141d1397f3e4349e1e0717a80158c7d67b65db9

See more details on using hashes here.

File details

Details for the file project_nebula-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for project_nebula-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 10e66e414bc85847e8674ac75f88d88a6dfaeaeed25eaf5b5c9d0e46c887388a
MD5 bd0f696f5152fa0ab607f748c7d44636
BLAKE2b-256 55d6228cc90be5670edc2cc986671e3ef2b8bf80b68c1a19e6ddbfd5950d9756

See more details on using hashes here.

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