Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

This project is deprecated, and you need to migrate to AltAPI. this version will not be maintained.

PyPi: https://pypi.org/project/AltAPI

Github: https://github.com/amogus-gggy/AltAPI

Nebula

Simple ASGI micro framework for Python, which supports both HTTP and WebSockets.

Changelog

Version 1.1

  • Added caching system (InMemoryCache, CacheMiddleware, @cache decorator)
  • Improved render_template() and Jinja2Templates integration
  • Added automatic static file serving via static_directory parameter
  • Minor improvements for static and templates directory handling

Installation

pip install project-nebula

Usage

from nebula import Nebula
from nebula.http import 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}"})


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


# Run server directly
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

Run

python examples/app.py

Or with uvicorn directly:

uvicorn examples.app:app --reload

Or using app.run():

python your_app.py

Project Structure

src/nebula/
├── __init__.py          # Main package exports
├── app.py               # Main Nebula application class
├── router.pyx           # Cython router (optimized)
├── http/                # HTTP components
│   ├── __init__.py
│   ├── request.py       # Request handling
│   └── responses.py     # Response classes
├── websocket/           # WebSocket support
│   ├── __init__.py
│   └── ws.py
├── templating/          # Template rendering (Jinja2)
│   ├── __init__.py
│   ├── templates.py
│   └── default_templates.py
├── caching/             # Caching system
│   ├── __init__.py
│   └── cache.py
└── middleware/          # Middleware support
    ├── __init__.py
    └── middleware.py

Recommended Imports

# Main application
from nebula import Nebula

# HTTP components
from nebula.http import Request, JSONResponse, HTMLResponse, PlainTextResponse, StreamingResponse, FileResponse, RedirectResponse

# WebSocket
from nebula.websocket import WebSocket, WebSocketState

# Templates
from nebula.templating import Jinja2Templates, render_template

# Caching
from nebula.caching import cache, InMemoryCache, CacheMiddleware

# Middleware
from nebula.middleware import Middleware, BaseMiddleware

Features

  • ASGI compliant
  • JSON and HTML responses
  • Typed path parameters (/users/{id:int}, {name:str}, {value:float})
  • Request body parsing (JSON, text)
  • Multiple HTTP methods (GET, POST, PUT, DELETE)
  • Sync and async handlers
  • Full WebSocket support
  • Optimized Cython router
  • Static file mounting (automatic via static_directory)
  • Template rendering (Jinja2)
  • Multiple response types (PlainText, Streaming, File, Redirect)
  • Built-in caching with InMemoryCache
  • Built-in server (app.run())

Metadata

Release files for project-nebula 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for project-nebula 1.1.1
File Size Uploaded Provenance Actions
project_nebula-1.1.1.tar.gz 121.1 kB Without provenance Details for project_nebula-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for project-nebula 1.1.1
File Interpreter ABI Platform Actions
project_nebula-1.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for project_nebula-1.1.1-cp312-cp312-win_amd64.whl

Total release size: 280.2 kB

Release files / project_nebula-1.1.1.tar.gz

Download URL project_nebula-1.1.1.tar.gz
Size 121.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f32337253f20cc7e4467e3988632936ebb8b8f3b91f2441ad32679c3b1323f5f
BLAKE2b-256 checksum
How to use checksums
f1419e28fd92c19f6dc19a5b6d2c66b13862ea6e9e638e5ed33f8b24a04cb234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release files / project_nebula-1.1.1-cp312-cp312-win_amd64.whl

Download URL project_nebula-1.1.1-cp312-cp312-win_amd64.whl
Size 159.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
dd585ed6325b98c97fe31690d7d388c5111ce6cf4db395ab7504204e98d9c84e
BLAKE2b-256 checksum
How to use checksums
a3ae8307740ead44e473459cc158042cc56aebe500b4ee130f8c21c3c951497c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Security for project-nebula 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page