Skip to main content

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

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.py and 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 use orjson.
  • 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_mcp module exposes the existing RPC registry as stateless server/discover, tools/list, and tools/call HTTP endpoints without adding runtime dependencies.
  • Cloudflare Python WorkersNight.cloudflare_fetch() bridges Workers Requests into Night, while Night.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 / 24night_node.mjs runs the same Night application under Node through Pyodide and Web-standard Request / Response.
  • Netlify Functions — the official Node 24 template uses Netlify's modern Request -> Response Functions 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:

  1. Quickstart
  2. HTTP guide
  3. Application and routing reference
  4. Request / Response reference
  5. Tooling and CLI
  6. Deployment

Additional guides:

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

all_night-0.1.7.tar.gz (63.4 kB view details)

Uploaded Source

Built Distribution

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

all_night-0.1.7-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

Details for the file all_night-0.1.7.tar.gz.

File metadata

  • Download URL: all_night-0.1.7.tar.gz
  • Upload date:
  • Size: 63.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for all_night-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b2713d709cf0344653f43544f688c5ce52d9b50bdae6340f25f0d9e9633e1ef9
MD5 829d34e65f02832e6b1a95f2249a3570
BLAKE2b-256 90c0531beec99e22bb8235d2ab6954f3e6fe5a46f8379241a79566abcdeb2846

See more details on using hashes here.

File details

Details for the file all_night-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: all_night-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 48.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for all_night-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fbfdf842c9eb8bbee0b9ea34ff3b3d1e0d39ea7af0b6d3e8c06b80f652184825
MD5 b05a1399328f2a00a101b86836d02812
BLAKE2b-256 c48ce2c6635b2119a03c02851b51db0f9fca6a2c9268d3f7de4fc1b76bc4e3cb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.8

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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