From c4cc8303d37dc70c42f3d509c1c9293315a84e17 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 11 Jul 2018 16:46:44 +0100 Subject: [PATCH] Add FileResponse to README --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index c65f6a06..3f8211af 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,30 @@ class App: await response(receive, send) ``` +### FileResponse + +Asynchronously streams a file as the response. + +Takes a different set of arguments to instantiate than the other response types: + +* `path` - The filepath to the file to stream. +* `headers` - Any custom headers to include, as a dictionary. +* `media_type` - A string giving the media type. If unset, the filename or path will be used to infer a media type. +* `filename` - If set, this will be included in the response `Content-Disposition`. + +```python +from starlette import FileResponse + + +class App: + def __init__(self, scope): + self.scope = scope + + async def __call__(self, receive, send): + response = FileResponse('/statics/favicon.ico') + await response(receive, send) +``` + --- ## Requests -- 2.47.3