servestatic
Production-grade static file server for Python WSGI & ASGI.
What it is and what it does
ServeStatic is a static file server middleware for Python web applications that handles compression, cache headers, and CDN integration automatically. It works as a drop-in middleware for ASGI and WSGI apps, or as a standalone server, and is designed to simplify deployments on platforms like Heroku and OpenShift where external services are unavailable or undesirable.
The package pre-computes file metadata and headers at initialization, then serves requests with minimal overhead. It automatically handles Accept-Encoding negotiation, sets far-future cache headers for immutable files, and integrates with CDNs to ensure the vast majority of traffic bypasses your application entirely. A CLI provides utilities for multi-format compression, filename hashing, and manifest generation. Django users get extra auto-configuration features.
Use it for:
- Deploy a Django or FastAPI app to Heroku or OpenShift without managing a separate Nginx instance.
- Serve static assets behind a CDN with automatic cache-busting via filename hashing.
- Eliminate S3 push-based deployment complexity by serving static files directly from your app with CDN caching.
- Automatically compress and serve gzip or brotli variants of CSS and JavaScript based on client Accept-Encoding.
- Run a self-contained production app that handles both dynamic content and static files without external dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ServeStatic serves static files efficiently from Python ASGI/WSGI applications with automatic compression, cache headers, and CDN integration, eliminating the need for separate web servers or external storage services.
Yes. ServeStatic is production-stable, actively maintained, has no known vulnerabilities, and solves a real deployment problem—especially on PaaS platforms. The single lightweight dependency and low install friction make it a practical choice. Use it if you need static file serving without external infrastructure; skip it if you already have Nginx or S3 in your stack.
Install
servestatic on PyPI
pip
pip install servestaticuv
uv add servestaticpoetry
poetry add servestaticInstalling servestatic
Before you install
Low friction: single pure-Python dependency (asgiref), wheel-only distribution, and active maintenance with a recent release 68 days ago. Supports Python 3.10 through 3.14.
License in practice
MIT license (permissive) allows free use, modification, and distribution in commercial and private projects with minimal restrictions.
Quickstart
pip install servestatic
from servestatic import ServeStaticMiddleware
app = ServeStaticMiddleware(app, root='staticfiles')
Requires Python 3.10 or later; asgiref must be installed as a runtime dependency.
Verify before relying
- Whether the package's performance claims (dictionary lookup, sendfile syscall) are verified under real-world load.
- Specific CDN providers tested or recommended for optimal caching behavior.
- Whether Django auto-configuration features are documented with examples.
- Compression format support (gzip, brotli, zstd) and their default enablement.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — asgiref |
| Maintenance | actively maintained — 68 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 179,423/month — #10,172 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: servestatic-4.3.1-py3-none-any.whl
Keywords: asgi, django, http, server, static, staticfiles, wsgi
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
whitenoiseWhiteNoise serves static files directly from a…
permissive · top 5,000 on PyPI
django-herokuConfigures Django applications for Heroku…
permissive · top 15,000 on PyPI
static3Serves static and templated content over WSGI,…
copyleft · top 15,000 on PyPI
dj-staticWraps a WSGI application to serve static files…
permissive · top 15,000 on PyPI
gunicornGunicorn is a WSGI and ASGI HTTP server for…
permissive · top 1,000 on PyPI
granianGranian is a Rust-based HTTP server that runs…
permissive · top 5,000 on PyPI
brotli-asgiBrotliMiddleware adds Brotli compression to…
permissive · top 15,000 on PyPI
Flask-CompressFlask-Compress automatically compresses Flask…
permissive · top 5,000 on PyPI
a2wsgiConverts between WSGI and ASGI applications…
permissive · top 5,000 on PyPI
pypiserverRuns a minimal PyPI-compatible package server…
permissive · top 5,000 on PyPI