2026-04-17 19:21:49 +02:00
2026-04-13 00:13:03 +02:00
2026-04-17 01:21:00 +02:00
2026-04-17 00:48:44 +02:00
2026-04-14 21:46:41 +02:00
2026-04-11 17:58:39 +02:00
2026-04-17 00:48:44 +02:00
2026-04-13 00:13:03 +02:00
2026-04-12 23:52:48 +02:00
2026-04-12 23:22:33 +02:00
2026-04-17 00:48:44 +02:00
2026-04-17 19:21:49 +02:00

Stapler

logo.svg

usage: stapler [-h] [--debug | --no-debug] [-d DATA_DIR] [--certificates | --no-certificates] [--certbot | --no-certbot]
               [--self-signed-path SELF_SIGNED_PATH] [--certbot-conf CERTBOT_CONF] [--certbot-www CERTBOT_WWW]
               [--host HOST] [--http-port HTTP_PORT] [--https-port HTTPS_PORT] [--https | --no-https] [-t TOKEN_SALT]
               [--max-size-bytes MAX_SIZE] [-b BIND]
               COMMAND ...

Static pages as simple as a gzip file

positional arguments:
  COMMAND
    run                 Run Stapler server
    renew               Renew certificates
    token               Generate a new token

options:
  -h, --help            show this help message and exit
  --debug, --no-debug
  -d, --data-dir DATA_DIR
                        directory where pages are/will be stored (default: ./data)
  --certificates, --no-certificates
                        Handle certificates (default: true)
  --certbot, --no-certbot
                        Use Certbot (default: true)
  --self-signed-path SELF_SIGNED_PATH
                        Self-signed certificates dir (default: ./data/.certificates)
  --certbot-conf CERTBOT_CONF
                        Certbot config dir (default: /etc/letsencrypt)
  --certbot-www CERTBOT_WWW
                        Certbot www dir (default: ./data/.certbot)
  --host HOST           server default host (default: localhost)
  --http-port HTTP_PORT
                        server http port (default: 80)
  --https-port HTTPS_PORT
                        server https port (default: 443)
  --https, --no-https   Use https (implies --certificates) (default: true)
  -t, --token-salt TOKEN_SALT
                        salt for tokens generation
  --max-size-bytes MAX_SIZE
                        max size of accepted archives (in bytes) (default: 2000000)
  -b, --bind BIND       server bind address (default: 0.0.0.0)

(Each option can be supplied with equivalent environment variable.)

Endpoints

Create/update page

PUT /{page}/
# create archive from 'dist' dir and upload to /my-project/
tar -czC dist . | curl -X PUT \
  --data-binary @- \
  -H 'X-Token: <TOKEN>' \
  https://stapler-host/my-project/

# create archive from 'dist' dir and upload to /my-project/ and myproject.example.com
tar -czC dist . | curl -X PUT \
  --data-binary @- \
  -H 'X-Token: <TOKEN>' \
  -H 'X-Host: myproject.example.com' \
  https://stapler-host/my-project/

Delete page

DELETE /{page}/
# delete /my-project/
curl -X DELETE \
  -H 'X-Token: <TOKEN>' \
  https://stapler-host/my-project/

Development

TODO

  • basic http server
  • docker container
  • env instead of args when available
  • PUT gzip data into /data/xxx
  • DELETE request
  • max file size
  • .host in /data/xxx can be translated as host in GET /
  • header to setup .host file instead of in archive
  • ignore .gitignore/.host etc at root
  • cerbot install in container + path env/arg
  • redirect /.well-known/acme-challenge to specific path
  • certbot/self-signed create/renew in specific dir
  • better logger
  • renew command
  • https mode w/ multiple hosts
  • create certificate on request
  • certbot copy certificates for unique path
  • better error page
  • add favicon.ico + special path
  • http.server security
  • launch separate upgrade 80->443 server when https
  • token management with "generate" command and bind path to specific token
  • docker compose example + .env
  • proper doc
  • unit tests
  • 404 GET on host not found
  • 403 PUT on host already taken
  • X-Redirect
  • X-Proxy

Makefile targets

Usage: make [target1] [target2] ...

Commands/Targets:
help                 show this message
uv-sync              uv sync
uv-upgrade           uv sync upgrade
ruff                 ruff check
ruff-fix             ruff check (and fix)
ruff-format          ruff format
ruff-format-check    ruff format (check only)
ty                   ty check
docker-build         docker build
docker-run           docker run
install              install project
update               update project dependencies
format               format project
lint                 lint project
build                build project
start                start server in localhost

Environment:
UV = uv
RUFF = uv run --active ruff
TY = uv run --active ty
DOCKER = docker
DOCKER_TAG = localhost/stapler:latest
TOKEN = secret
PORT = 8080
S
Description
No description provided
Readme 614 KiB
Stapler 1.4.0 Latest
2026-05-11 17:26:59 +02:00
Languages
Python 97.8%
Makefile 1.9%
Dockerfile 0.3%