Skip to content

Recipes

Copy-paste solutions for common tasks. Each links to the relevant guide.

Share this folder with the phone in my hand

servery --profile share --qr

Binds the LAN with a self-signed cert and prints a QR code to scan. → Sharing on a LAN

Let someone drop files to me (securely)

servery --upload --auth me:secret --tls-self-signed --bind 0.0.0.0
# or the preset:
servery --profile inbox --auth me:secret --qr

Uploads & authentication

Mount the share as a drive in Finder/Explorer

# read-only:
servery --dav --bind 0.0.0.0
# read/write, with a password:
servery --dav --dav-write --auth me:secret --bind 0.0.0.0

WebDAV

Get a real, browser-trusted HTTPS certificate automatically

sudo servery --acme example.com --acme-email you@example.com \
     --acme-production --bind 0.0.0.0 --port 443

Needs the domain pointed at you and port 80 reachable for the challenge. → HTTPS & certificates

Serve a built front-end (SPA) with client-side routing

servery ./dist --spa

Serving files

Serve static assets as a CDN-style origin

servery ./assets --profile cdn        # long cache + CORS + HTTP/2 (TLS)

Compression, caching & headers

Download a whole folder in one click

Append to any directory URL:

…/photos/?archive=zip
…/photos/?archive=tar.gz

Or tick a few files and hit zip selected. → Serving files

Run a local API behind the same origin as my files

servery --proxy /api=http://localhost:8001

Running apps & proxying

Keep an access log for analytics

servery --access-log access.log --access-log-format combined

Access logging

Use it in a test (ephemeral port, background thread)

import threading
from servery import Config, make_server, server_url

server = make_server(Config.create("./fixtures", port=0))
threading.Thread(target=server.serve_forever, daemon=True).start()
base = server_url(server)   # http://127.0.0.1:<random>/
# … make requests against base …
server.shutdown()

Using servery as a library

Run it with no install at all

curl -fsSL https://github.com/mjbommar/servery/releases/latest/download/servery.py | python3 - ./public -p 8000

Getting started