All-Night
Night is a tiny, single-file ASGI web framework for Python 3.11+ with portable Web-runtime adapters for browsers, Node.js, and serverless platforms.
The core stays dependency-free. The recommended standard profile adds the fast CPython server stack, Midnight, and Cloudflare development/runtime helpers.
Install
Minimal dependency-free core:
pip install -U all-night
Recommended full install:
pip install -U "all-night[standard]"
all-night[standard] installs uvicorn[standard], orjson, workers-runtime-sdk, and the separate all-night-midnight distribution. Starting with 0.1.5, the night_midnight* modules are no longer bundled in the minimal all-night wheel.
from night import Night
app = Night()
@app.get("/")
def index():
return {"hello": "night"}
@app.get("/users/<int:user_id>")
def user(user_id: int):
return {"id": user_id}
Run with Night's CLI:
night run app.py
or any ASGI server:
uvicorn app:app --reload
NightCLI
nightcli manages a Night project through a small, portable night.toml.
It creates a project without forcing a hosting platform and can validate the
configured application before it is deployed.
nightcli new my-api --template api
cd my-api
nightcli doctor
nightcli check
nightcli routes --format json
nightcli dev
Templates are api, site, midnight, and cloudflare. Use
nightcli info to inspect the nearest project, or pass
--project path/to/project from elsewhere. nightcli openapi writes the app's OpenAPI document to openapi.json (or a project-relative --output path).
Fast mode
With the standard profile installed, enable Night's optional CPython fast path with app.fast():
from night import Night
app = Night().fast()
@app.get("/")
def index():
return {"hello": "fast night"}
app.fast() switches Night's dict/list response serialization to orjson. When the application is launched with night run, Night also selects uvloop, httptools, and websockets when those backends are available from uvicorn[standard]. If you launch with an external ASGI command such as uvicorn app:app, that server still controls its own event loop/backend selection; Uvicorn's auto mode will normally use its installed standard accelerators.
Why Night
- Single-file core — the framework core stays in
night.pyand has no required runtime dependencies on normal CPython. - Fast routing — static routes use direct indexes; common dynamic routes are compiled into specialized fast paths so large route tables do not require linear scans.
- Fast response path — common JSON/text/HTML responses avoid unnecessary temporary header dictionaries and
app.fast()can useorjson. - Sync + async — handlers are classified at registration time and Night compiles route-specific invokers to reduce per-request branching.
- HTTP batteries included — JSON, forms, multipart uploads, cookies, sessions, CSRF helpers, streaming, SSE, WebSocket, static files, middleware, hooks, and error handlers.
- Typed request bodies — validate nested dataclasses, optional values, and
list[T]request bodies. - Tooling — built-in in-process
TestClient, CLI, named routes, OpenAPI generation, extensions, JSON-RPC, and a lightweight SQLite ORM. - MCP 2026-07-28 — the optional
night_mcpmodule exposes the existing RPC registry as statelessserver/discover,tools/list, andtools/callHTTP endpoints without adding runtime dependencies. - Cloudflare Python Workers —
Night.cloudflare_fetch()bridges Workers Requests into Night, whileNight.cloudflare_rpc()exposes the same@app.rpc(...)registry over Workers RPC/Service Bindings. - Vercel Functions — Vercel's Python runtime accepts Night directly as an ASGI
app; no request/response adapter is needed. - Node.js 22 / 24 —
night_node.mjsruns the same Night application under Node through Pyodide and Web-standardRequest/Response. - Netlify Functions — the official Node 24 template uses Netlify's modern
Request -> ResponseFunctions API and the shared Night Node adapter. - Browser Night — run Night entirely in a browser tab with Pyodide.
MCP
from night import Night
from night_mcp import enable_mcp
app = Night()
mcp = enable_mcp(app)
@mcp.tool(description="Add two integers")
def add(a: int, b: int):
return {"value": a + b}
Existing @app.rpc(...) methods are also visible as MCP tools. See the MCP guide.
Cloudflare Workers
Night keeps the Workers adapter in the core package. The standard profile additionally installs workers-runtime-sdk on Python 3.13+ for local typing/runtime integration.
For actual Python Workers deployment, use Cloudflare's Workers-native toolchain rather than Uvicorn:
[project]
dependencies = ["all-night==0.1.5"]
[dependency-groups]
dev = [
"workers-py",
"workers-runtime-sdk",
]
from night import Night
from workers import WorkerEntrypoint
app = Night()
@app.get("/")
def index():
return {"hello": "edge"}
class Default(WorkerEntrypoint):
async def fetch(self, request):
return await app.cloudflare_fetch(request)
Cloudflare Python Workers run inside Pyodide, so app.fast()'s CPython uvloop/httptools path is not used there. See the Cloudflare Workers guide.
Midnight
Midnight is Night's bidirectional Python ↔ HTML bridge for DOM events, structured DOM updates, custom events, forms, reusable components, and optional WebSocket transport.
Since 0.1.5, Midnight is installed through the standard profile:
pip install -U "all-night[standard]"
This pulls the separate all-night-midnight wheel, which provides night_midnight, night_midnight_component, night_midnight_dev, and night_midnight_form. See the Midnight guide.
Browser Night
Night can run entirely in the browser through Pyodide and the night_web adapter. No Python server is required: routes execute inside the tab and Web-style requests are bridged into the same Night application.
The GitHub Pages demo lives under deploy/browser-night. See the Browser Night guide.
Deployment
- Normal ASGI / CPython — Uvicorn, Hypercorn, or another ASGI server
- Vercel Functions — direct ASGI application
- Cloudflare Python Workers — Workers-native
cloudflare_fetch()bridge - Node.js 22 / 24 — Pyodide +
night_node.mjs - Netlify Functions — Node adapter and Web-standard Request/Response
- Browser Night — Pyodide inside the browser tab
See Deployment.
Documentation
Start with the documentation index.
Recommended reading order:
- Quickstart
- HTTP guide
- Application and routing reference
- Request / Response reference
- Tooling and CLI
- Deployment
Additional guides:
- Templates
- Realtime / WebSocket / SSE
- Midnight
- Browser Night / Pyodide
- Node.js runtime
- MCP
- Cloudflare Workers
- Vercel Functions
- Netlify Functions
- 日本語ドキュメント
For coding agents and automated tooling, see SKILL.md.
Version
Current release target: 0.1.5. Night requires Python 3.11+.
Night is alpha software. Benchmark numbers in this repository are development measurements; in-process test clients do different bookkeeping and should not be treated as production HTTP throughput results.
Metadata
Release files for all-night 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| all_night-0.1.8.tar.gz | 76.9 kB | Without provenance | Details for all_night-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| all_night-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for all_night-0.1.8-py3-none-any.whl |
Total release size: 137.7 kB
Release files / all_night-0.1.8.tar.gz
| Download URL | all_night-0.1.8.tar.gz |
|---|---|
| Size | 76.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
360f9612630f37e6c855e0e78bace902138a2a7197a5108e50877bcb28c1f0e6
|
|
BLAKE2b-256 checksum How to use checksums |
310b90a30e612e9c229f26c2352c997b90666ecbbe8842d1d6625f8cbecd8572
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / all_night-0.1.8-py3-none-any.whl
| Download URL | all_night-0.1.8-py3-none-any.whl |
|---|---|
| Size | 60.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b43c851efffc0517841ab87a2c359f913e86bda1d522c7dead2f03dd5d96b683
|
|
BLAKE2b-256 checksum How to use checksums |
c0acbf5a2d287707283b8de0702d6a4214bd0e51899928feecc2e79e899e0781
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for all-night 0.1.8
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.