Stardust is micro web framework inspired by serverless and lambda deployments.
Project description
Stardust
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
/forGETandPOST. - Passes the incoming
Requestobject when the function accepts parameters. - Wraps non-
Responsereturn values inJSONResponse. - 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
Responsesubclass is returned unchanged. - Status codes and headers should be controlled by returning a
Responseobject.
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 toapp.py--file: explicit target path to a Python file or package directory--host: bind host, defaults to0.0.0.0--port: bind port, defaults to8000--log-level: one ofcritical,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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stardust-0.0.8.tar.gz.
File metadata
- Download URL: stardust-0.0.8.tar.gz
- Upload date:
- Size: 33.1 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16769970d98106dd586720107416ab5af5d5ec4bc441b8f0d123defe5a27298d
|
|
| MD5 |
1816f7c4053e76c64a56fa383308b09e
|
|
| BLAKE2b-256 |
6090a85820ee6b38cf4bfaf932d31c3425f72cb64cfaae769996bd20f3a917f5
|
File details
Details for the file stardust-0.0.8-py3-none-any.whl.
File metadata
- Download URL: stardust-0.0.8-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da03fba07e3d71aaa972b37def2a3e622dd4bfe75d696388d7d6712a67a087d1
|
|
| MD5 |
c36ded691c20011aeb517b37575897a9
|
|
| BLAKE2b-256 |
b92d72cb56229cd3dd1ee9662b0dd906f18024dceec5f348f9f237d6051febc0
|