Skip to main content

Python port of vercel/serve — static file serving and directory listing

Project description

ssserve

(spelled hisss serve)

Python port of vercel/serve — static file serving and directory listing. (vibecoded)

Run

run directly without installing:

uvx ssserve

Install

uv tool install ssserve

Usage

ssserve [path] [options]

Defaults to current directory and port 3000.

Options

Flag Description
-l, --listen URI Listen endpoint (default: tcp://0.0.0.0:3000, multi-allowed)
-s, --single SPA mode — rewrite 404s to index.html
-C, --cors Enable CORS headers
-u, --no-compression Disable gzip compression
-S, --symlinks Resolve symlinks
-L, --no-request-logging Disable request logging
-c, --config PATH Path to serve.json
--no-etag Disable ETag (use Last-Modified)
--ssl-cert FILE SSL certificate (PEM)
--ssl-key FILE SSL private key (PEM)
--ssl-pass FILE SSL passphrase file
--no-port-switching Don't auto-switch if port is taken
-r, --live-reload Live reload browser on file changes
-d, --debug Debug output
--version Show version
--help Show help

Examples

# Serve current directory on port 3000
ssserve

# Serve specific directory on port 5000 with CORS
ssserve -l 5000 -C ./my-site

# Serve with live reload for development
ssserve -r .

# Serve with live reload on custom port
ssserve -l 5000 -r ./my-site

# Serve with HTTPS
ssserve --ssl-cert cert.pem --ssl-key key.pem

# SPA mode for React/Vue apps
ssserve -s dist

# Multiple listeners
ssserve -l tcp://0.0.0.0:3000 -l unix:/tmp/serve.sock

Configuration

Create a serve.json file in the served directory:

{
  "public": "_site",
  "cleanUrls": true,
  "rewrites": [
    { "source": "/api/**", "destination": "/index.html" }
  ],
  "redirects": [
    { "source": "/old", "destination": "/new", "type": 302 }
  ],
  "headers": [
    {
      "source": "**/*.@(jpg|png)",
      "headers": [
        { "key": "Cache-Control", "value": "max-age=7200" }
      ]
    }
  ],
  "directoryListing": false,
  "trailingSlash": true,
  "etag": true,
  "symlinks": false,
  "renderSingle": false
}

Testing

E2E tests verify behaviour, performance, and resource consumption against a live server process.

# Run all tests
uv run pytest tests/ -v

# Run only e2e tests
uv run pytest tests/e2e/ -v

Test layout

File Tests What it covers
tests/e2e/test_behavior.py 47 File serving, directory listing, clean URLs, redirects, rewrites, CORS, gzip, ETag/304, Range requests, SPA mode, custom headers, symlinks, path traversal
tests/e2e/test_livereload.py 8 Script injection, /__ssserve/lr-check endpoint, file change detection, version tracking
tests/e2e/test_performance.py 8 Latency (p50/p95/p99), TTFB, gzip vs raw, concurrent throughput — measure-only
tests/e2e/test_resources.py 7 RSS memory, CPU usage, file descriptor count — measure-only

Dependencies: pytest, psutil (see [dependency-groups] in pyproject.toml).

Tests run automatically on CI via .github/workflows/tests.yml.

Benchmarks

Micro-benchmarks using airspeed velocity track performance of core operations across commits:

sserve benchmark

Benchmark What it measures
TimeRouteToRegex Pattern compilation for route matching
TimeMatchGlob Glob matching and exclusion lists
TimeParseByteRange HTTP Range header parsing
TimeFormatSize File size formatting
TimeFormatDate Date formatting
TimeParseListen Listen URI parsing
TimeMergeConfig Config merging from serve.json
TimeRenderListing HTML directory listing rendering (100 files)
# Validate benchmarks
uv run asv check --python=same

# Quick run
uv run asv run --python=same --quick

# Full run across configured pythons
uv run asv run

Benchmarks run automatically on CI via .github/workflows/benchmarks.yml.

License

MIT

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

ssserve-0.3.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

ssserve-0.3.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file ssserve-0.3.1.tar.gz.

File metadata

  • Download URL: ssserve-0.3.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ssserve-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bf70e3b2c292a451ed58d01ae1018330f756a139f08897a840dd18cff996b8c1
MD5 a810e92df2e551f49da7f61db41a794c
BLAKE2b-256 6ba0d75bd8e4be530ede8fc78bd202a9662068c0d7be29c9886587dccb3e193c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ssserve-0.3.1.tar.gz:

Publisher: publish.yml on prakashsellathurai/ssserve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ssserve-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ssserve-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ssserve-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e9c2c5189eb46c2008db52acc2fa2a7bcdab9eadf863b2bdd99ca60c9d557c5
MD5 a87078e38bad86a6163a16f9d8934897
BLAKE2b-256 f71978cb24fbea8173d96e33fce71fe1423fb07a532f10a8f27d2b74edeb81d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ssserve-0.3.1-py3-none-any.whl:

Publisher: publish.yml on prakashsellathurai/ssserve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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