Skip to main content

Cypache

A fast, security-first HTTP server for Python on Linux, written in Cython (C++ mode) on top of fastepoll. Python handlers run natively in the server's worker processes; there is no CGI or FastCGI hop. It serves static files and Python apps over HTTP/1.1 and, with TLS, HTTP/2, and is strict by design: a request that a proxy in front could read differently is refused, static files are confined to their root by the kernel, and every limit and timeout has a safe default.

Install

A server, on Ubuntu or Debian, as root: Cypache as a systemd service on ports 80 and 443, serving each folder in /var/www/sites as a site named after its host:

git clone https://github.com/Source61/cypache && cypache/tools/install

Run tools/install again after git pull in the clone to upgrade.

On its own, as a library: pip install cypache in a virtual environment, which installs fastepoll too. The wheels are for CPython 3.12 to 3.15 on Linux x86-64 with glibc 2.34 or newer, OpenSSL 3 and libnghttp2 1.60 or newer (libnghttp2-14), which stay the system's, so their security updates apply.

Quick start

On a server from tools/install, a site is a folder, and each .py in its controllers/ answers the path it's named after:

mkdir -p /var/www/sites/example.com/public /var/www/sites/example.com/controllers
echo "<h1>Hello</h1>" > /var/www/sites/example.com/public/index.html
printf 'def get(request):\n  return "<h1>News</h1>"\n' > /var/www/sites/example.com/controllers/news.py

http://example.com/ is the static page and /news the handler, served a second or so after saving. For HTTPS, get a certificate with certbot (man cypache).

As a library, a config is a Python script that builds its sites and calls serve():

import cypache

def hello(request):
  return "<h1>Hello</h1>"

def user(request):
  return {"path": request.path, "query": request.query}

site = cypache.Site("example.com", "www.example.com", routes={"/": hello, "/api/user": user})
cypache.serve([site], http=8080)
python3 -I config.py

Run it as an unprivileged user: handlers run with the server's privileges. The config runs as code with them too, so it must not be writable by the server's user.

Documentation

The man pages are the reference. tools/install installs them; in a clone, read them with man -l man/<page>.

  • man cypache: running it as a service: sites in /var/www/sites, HTTPS with certbot, upgrading, signals, security, logs and files.
  • man cypache-config: the config: Site and serve() with every option, timeouts, HTTPS and HTTP/2, static files, reloading, the access log, and what requests are refused.
  • man cypache-apps: a site's Python: handlers, the request, file-based apps and views, threads, uploads.

License

See LICENSE.txt.

Metadata

Release files for cypache 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cypache 0.1.1
File Actions
cypache-0.1.1-cp315-cp315-manylinux_2_34_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.34+ x86-64 Details for cypache-0.1.1-cp315-cp315-manylinux_2_34_x86_64.whl
cypache-0.1.1-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details for cypache-0.1.1-cp314-cp314-manylinux_2_34_x86_64.whl
cypache-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details for cypache-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl
cypache-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details for cypache-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl

Total release size: 4.1 MB

Release files / cypache-0.1.1-cp315-cp315-manylinux_2_34_x86_64.whl

Download URL cypache-0.1.1-cp315-cp315-manylinux_2_34_x86_64.whl
Size 1.0 MB
Tags CPython 3.15 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
b2fb2e126d7d0aa34f82a95aae5af8cc2df13c1f69648d248dda52188126750d
BLAKE2b-256 checksum
How to use checksums
f0e1be612747e2d70e8ddec2525f255ce3057c5df7d48824e2ecbea075cb720a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / cypache-0.1.1-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL cypache-0.1.1-cp314-cp314-manylinux_2_34_x86_64.whl
Size 1.0 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
ad8e9f7946073786822ada6b8114ae12f2fc08926907c52bbed3340ab304e7b2
BLAKE2b-256 checksum
How to use checksums
fbbb753b32bdef1ecd546052f4ce2583df9c48a1c7d33f01586373238d592674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / cypache-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL cypache-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl
Size 1.0 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c4d3371d8178c82cca8498819eef2304c76410a41e6c270b87439e5ab4dea869
BLAKE2b-256 checksum
How to use checksums
7f71e782eebabbe4780601e51d230d20d987de149cda59b3dcf2f0bfd8e228f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / cypache-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL cypache-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c23cf1cd014d522ff7e59c26353b8eaa58e37c6bfe96ed93ef814f368d6c3bfa
BLAKE2b-256 checksum
How to use checksums
ebe4f77074c2d6f0f72252bde85d59a36f7e521ef3b3e11f5ecf96e511ebb4b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for cypache 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

4 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page