Skip to main content

Stardust is micro web framework inspired by serverless and lambda deployments.

Project description

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.

Project details


Download files

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

Source Distribution

stardust-0.0.8.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

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

stardust-0.0.8-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

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

Hashes for stardust-0.0.8.tar.gz
Algorithm Hash digest
SHA256 16769970d98106dd586720107416ab5af5d5ec4bc441b8f0d123defe5a27298d
MD5 1816f7c4053e76c64a56fa383308b09e
BLAKE2b-256 6090a85820ee6b38cf4bfaf932d31c3425f72cb64cfaae769996bd20f3a917f5

See more details on using hashes here.

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

Hashes for stardust-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 da03fba07e3d71aaa972b37def2a3e622dd4bfe75d696388d7d6712a67a087d1
MD5 c36ded691c20011aeb517b37575897a9
BLAKE2b-256 b92d72cb56229cd3dd1ee9662b0dd906f18024dceec5f348f9f237d6051febc0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page