forked from encode/starlette
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25990db
commit 352ccda
Showing
7 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
www.starlette.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
As well as the `FileResponse` class, Starlette also includes ASGI applications | ||
for serving a specific file or directory: | ||
|
||
* `StaticFile(path)` - Serve a single file, given by `path`. | ||
* `StaticFiles(directory)` - Serve any files in the given `directory`. | ||
|
||
You can combine these ASGI applications with Starlette's routing to provide | ||
comprehensive static file serving. | ||
|
||
```python | ||
from starlette.routing import Router, Path, PathPrefix | ||
from starlette.staticfiles import StaticFile, StaticFiles | ||
|
||
|
||
app = Router(routes=[ | ||
Path('/', app=StaticFile(path='index.html')), | ||
PathPrefix('/static', app=StaticFiles(directory='static')), | ||
]) | ||
``` | ||
|
||
Static files will respond with "404 Not found" or "406 Method not allowed" | ||
responses for requests which do not match. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters