Registry / web-framework / servestatic

servestatic

JSON →
library4.3.0pypypi✓ verified 84d ago

Production-grade static file server for Python WSGI & ASGI applications, with support for Django, compression, and content hashing. Current version: 4.3.0, released April 2025. Active development.

pip install servestatic
INSTALL
IMPORT
SIG · SERVESTATIC
S
servestatic
web-frameworkpythonv4.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ServeStatic
from servestatic.wsgi import ServeStatic
from servestatic import ServeStatic
WSGI class is in servestatic.wsgi, not top-level.
ServeStaticASGI
from servestatic.asgi import ServeStaticASGI
from servestatic import ServeStaticASGI
ASGI class is in servestatic.asgi.

Wrap any WSGI app with ServeStatic to serve static files.

from servestatic.wsgi import ServeStatic from flask import Flask, send_from_directory import os app = Flask(__name__) app.wsgi_app = ServeStatic(app.wsgi_app, root='/path/to/static') @app.route('/') def index(): return send_from_directory('/path/to/static', 'index.html') if __name__ == '__main__': app.run()
Debug
Known issues
breakingIn version 4.0.0, default immutable_file_test regex changed to match files hashed by servestatic --hash. Custom file patterns may no longer be treated as immutable.
fix
Set immutable_file_test explicitly if you rely on old behavior, e.g., ServeStatic(app, immutable_file_test=r'').
affects: >=4.0.0
breakingIn version 4.1.0, symlink following is now disabled by default for security. If your static directory uses symlinks, you must set allow_unsafe_symlinks=True.
fix
Pass allow_unsafe_symlinks=True to ServeStatic or set SERVESTATIC_ALLOW_UNSAFE_SYMLINKS=True in Django settings.
affects: >=4.1.0
deprecatedThe compression API via python -m servestatic.compress is deprecated as of 4.0.0. Use servestatic --compress CLI instead.
fix
Run `servestatic --compress` after installing with [cli] extras.
affects: >=4.0.0
gotchaWhen using Django, SERVESTATIC_USE_STATIC_ROOT (added in 4.2.0) is off by default. If you rely on collectstatic to populate STATIC_ROOT, serve from STATIC_ROOT directly only if you enable this setting.
fix
Set SERVESTATIC_USE_STATIC_ROOT = True in settings.py if you want ServeStatic to scan STATIC_ROOT at startup.
affects: >=4.2.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'servestatic'
Library not installed or installed in wrong environment.
fix
Run `pip install servestatic` in the correct Python environment.
ImportError: cannot import name 'ServeStatic' from 'servestatic'
Importing from wrong module; ServeStatic class is in servestatic.wsgi.
fix
Use `from servestatic.wsgi import ServeStatic` or `from servestatic.asgi import ServeStaticASGI` for ASGI.
TypeError: ServeStatic() missing 1 required positional argument: 'application'
First argument to ServeStatic must be a WSGI app.
fix
Wrap your existing WSGI app: `app.wsgi_app = ServeStatic(app.wsgi_app, root='...')`.
django.core.exceptions.ImproperlyConfigured: The SERVESTATIC setting is not configured
Django integration requires adding 'servestatic' to INSTALLED_APPS.
fix
Add 'servestatic' to INSTALLED_APPS in Django settings.
Upgrade
Version history
4.3.0latest on PyPI · released Apr 10, 2026
Audit
Dependencies
asgirefrequiredRequired for ASGI support and import correctness.
DjangooptionalOptional integration for Django settings and collectstatic.
Agent activity
44 hits · last 30 days
node
40
OpenAI (training)
1
Resources
servestatic — pip install servestatic · libregistry