{"id":28176,"library":"servestatic","title":"ServeStatic","description":"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.","status":"active","version":"4.3.0","language":"python","source_language":"en","source_url":"https://github.com/Archmonger/ServeStatic","tags":["static","wsgi","asgi","django","flask","compression","hashing","production"],"install":[{"cmd":"pip install servestatic","lang":"bash","label":"Install from PyPI"},{"cmd":"pip install servestatic[cli]","lang":"bash","label":"Install with CLI dependencies"}],"dependencies":[{"reason":"Required for ASGI support and import correctness.","package":"asgiref","optional":false},{"reason":"Optional integration for Django settings and collectstatic.","package":"Django","optional":true}],"imports":[{"note":"WSGI class is in servestatic.wsgi, not top-level.","wrong":"from servestatic import ServeStatic","symbol":"ServeStatic","correct":"from servestatic.wsgi import ServeStatic"},{"note":"ASGI class is in servestatic.asgi.","wrong":"from servestatic import ServeStaticASGI","symbol":"ServeStaticASGI","correct":"from servestatic.asgi import ServeStaticASGI"}],"quickstart":{"code":"from servestatic.wsgi import ServeStatic\nfrom flask import Flask, send_from_directory\nimport os\n\napp = Flask(__name__)\napp.wsgi_app = ServeStatic(app.wsgi_app, root='/path/to/static')\n\n@app.route('/')\ndef index():\n    return send_from_directory('/path/to/static', 'index.html')\n\nif __name__ == '__main__':\n    app.run()","lang":"python","description":"Wrap any WSGI app with ServeStatic to serve static files."},"warnings":[{"fix":"Set immutable_file_test explicitly if you rely on old behavior, e.g., ServeStatic(app, immutable_file_test=r'').","message":"In 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.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Pass allow_unsafe_symlinks=True to ServeStatic or set SERVESTATIC_ALLOW_UNSAFE_SYMLINKS=True in Django settings.","message":"In 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.","severity":"breaking","affected_versions":">=4.1.0"},{"fix":"Run `servestatic --compress` after installing with [cli] extras.","message":"The compression API via python -m servestatic.compress is deprecated as of 4.0.0. Use servestatic --compress CLI instead.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Set SERVESTATIC_USE_STATIC_ROOT = True in settings.py if you want ServeStatic to scan STATIC_ROOT at startup.","message":"When 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.","severity":"gotcha","affected_versions":">=4.2.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `pip install servestatic` in the correct Python environment.","cause":"Library not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'servestatic'"},{"fix":"Use `from servestatic.wsgi import ServeStatic` or `from servestatic.asgi import ServeStaticASGI` for ASGI.","cause":"Importing from wrong module; ServeStatic class is in servestatic.wsgi.","error":"ImportError: cannot import name 'ServeStatic' from 'servestatic'"},{"fix":"Wrap your existing WSGI app: `app.wsgi_app = ServeStatic(app.wsgi_app, root='...')`.","cause":"First argument to ServeStatic must be a WSGI app.","error":"TypeError: ServeStatic() missing 1 required positional argument: 'application'"},{"fix":"Add 'servestatic' to INSTALLED_APPS in Django settings.","cause":"Django integration requires adding 'servestatic' to INSTALLED_APPS.","error":"django.core.exceptions.ImproperlyConfigured: The SERVESTATIC setting is not configured"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}