static3

raw JSON →
0.7.0 verified Fri May 01 auth: no python maintenance

static3 is a simple WSGI middleware for serving static files (or mixed static/dynamic content). It is a fork of static with Python 3 support and additional features like arbitrary headers and precompressed content. Current version: 0.7.0. Release cadence is irregular; last release was in 2016.

pip install static3
error ModuleNotFoundError: No module named 'static3'
cause The import module is named 'static', not 'static3'.
fix
Change your import to 'from static import StaticMiddleware'.
error ImportError: No module named 'static'
cause The package is not installed. You may have installed 'static' (the old, Python 2-only package) instead of 'static3'.
fix
Run 'pip install static3' to install the Python 3 fork.
gotcha static3 is a fork of the unmaintained static library. Ensure you install static3, not static, for Python 3 support.
fix Use 'pip install static3' and import from 'static' module as before.
gotcha The package name on PyPI is 'static3', but the import module is 'static'. Do not import 'static3' directly.
fix Use 'from static import StaticMiddleware'.

Minimal WSGI server serving static files from /path/to/static/files at the /static URL prefix.

from wsgiref.simple_server import make_server
from static import StaticMiddleware

app = StaticMiddleware(my_wsgi_app, "/static", "/path/to/static/files")

if __name__ == "__main__":
    httpd = make_server("", 8000, app)
    print("Serving on port 8000...")
    httpd.serve_forever()