Skip to main content

Stardust

PyPI version Python Versions License: MIT

Stardust is a minimal ASGI microframework for serving a single Python function as an HTTP endpoint. It is built on top of Starlette and Uvicorn and is designed around a simple contract: load one local function, expose it at /, and convert its return value into an HTTP response.

What It Does

  • Loads a Python file or package directory.
  • Finds the first local function defined in that module.
  • Serves that function on / for GET and POST.
  • Passes the incoming Request object when the function accepts parameters.
  • Wraps non-Response return values in JSONResponse.
  • Enables permissive CORS by default.

Installation

pip install stardust

Requires Python 3.10 or newer.

Quick Start

Create app.py:

async def serve(req):
    return {"hello": "world"}

Run it:

stardust app.py

The app will be available at http://localhost:8000/.

Application Contract

Stardust looks for the first local function in the target module. That function can be:

  • async def serve(req): ...
  • async def serve(): ...
  • def serve(req): ...
  • def serve(): ...

If the function accepts at least one parameter, Stardust passes the Starlette Request object. If it accepts no parameters, it is called without arguments.

Return Values

  • dict, list, and other JSON-serializable values are returned as JSON.
  • Any Starlette Response subclass is returned unchanged.
  • Status codes and headers should be controlled by returning a Response object.

Example:

from starlette.responses import PlainTextResponse


async def serve(req):
    name = req.query_params.get("name", "world")
    return PlainTextResponse(f"hello {name}")

CLI

stardust [file]
stardust --file path/to/app.py --host 127.0.0.1 --port 9000 --log-level info --debug

Options:

  • file: optional positional target, defaults to app.py
  • --file: explicit target path to a Python file or package directory
  • --host: bind host, defaults to 0.0.0.0
  • --port: bind port, defaults to 8000
  • --log-level: one of critical, error, warning, info, debug
  • --debug: enables Starlette debug mode and Uvicorn access logs

If no local function is found, the CLI exits with status code 1.

Examples

The examples/ directory contains small runnable apps, including:

  • JSON responses
  • plain text responses
  • query parameter handling
  • multiple functions in one module
  • package-based app loading

Developer Documentation

Detailed developer documentation lives in docs/:

Local Development

uv sync --all-extras --dev
uv run pytest

License

MIT. See LICENSE.txt.

Release files for stardust 0.0.8

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

Source distribution (sdist)

Source distribution for stardust 0.0.8
File Size Uploaded
stardust-0.0.8.tar.gz 33.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stardust 0.0.8
File Interpreter ABI Platform
stardust-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / stardust-0.0.8.tar.gz

Download URL stardust-0.0.8.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
16769970d98106dd586720107416ab5af5d5ec4bc441b8f0d123defe5a27298d
BLAKE2b-256 checksum
How to use checksums
6090a85820ee6b38cf4bfaf932d31c3425f72cb64cfaae769996bd20f3a917f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / stardust-0.0.8-py3-none-any.whl

Download URL stardust-0.0.8-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da03fba07e3d71aaa972b37def2a3e622dd4bfe75d696388d7d6712a67a087d1
BLAKE2b-256 checksum
How to use checksums
b92d72cb56229cd3dd1ee9662b0dd906f18024dceec5f348f9f237d6051febc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
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