网页
综合
更新时间 2026-11-14 09:45:14
Static Files - Starlette
自动蜘蛛
starlette.dev
正文约 980 字
Starlette also includes a StaticFiles class for serving files in a given directory:
Signature: StaticFiles(directory=None, packages=None, html=False, check_dir=True, follow_symlink=False)
You can combine this ASGI application with Starlette's routing to provide comprehensive static file serving.
Static files will respond with "404 Not found" or "405 Method not allowed" responses for requests which do not match. In HTML mode if 404.html file exists it will be shown as 404 response.
The packages option can be used to include "static" directories contained within a python package. The Python "bootstrap4" package is an example of this.
By default StaticFiles will look for a statics directory in each package, you can change the default directory by specifying a tuple of strings.
You may prefer to include static files directly inside the "static" directory rather than using Python packaging to include static files, but it can be useful for bundling up reusable components.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。