mirror of https://github.com/encode/starlette.git
573 B
573 B
Starlette also includes a StaticFiles
class for serving a specific directory:
StaticFiles(directory)
- Serve any files in the givendirectory
.
You can combine this ASGI application with Starlette's routing to provide comprehensive static file serving.
from starlette.routing import Router, Mount
from starlette.staticfiles import StaticFiles
app = Router(routes=[
Mount('/static', app=StaticFiles(directory='static')),
])
Static files will respond with "404 Not found" or "405 Method not allowed" responses for requests which do not match.