diff --git a/docs/sanic/response.md b/docs/sanic/response.md index 627fbc7e..1a336d47 100644 --- a/docs/sanic/response.md +++ b/docs/sanic/response.md @@ -2,7 +2,7 @@ Use functions in `sanic.response` module to create responses. -- `text` - Plain text response +## Plain Text ```python from sanic import response @@ -13,7 +13,7 @@ def handle_request(request): return response.text('Hello world!') ``` -- `html` - HTML response +## HTML ```python from sanic import response @@ -24,7 +24,7 @@ def handle_request(request): return response.html('
Hello world!
') ``` -- `json` - JSON response +## JSON ```python @@ -36,7 +36,7 @@ def handle_request(request): return response.json({'message': 'Hello world!'}) ``` -- `file` - File response +## File ```python from sanic import response @@ -47,7 +47,7 @@ async def handle_request(request): return await response.file('/srv/www/whatever.png') ``` -- `stream` - Streaming response +## Streaming ```python from sanic import response @@ -60,7 +60,7 @@ async def index(request): return response.stream(streaming_fn, content_type='text/plain') ``` -- `redirect` - Redirect response +## Redirect ```python from sanic import response @@ -71,7 +71,9 @@ def handle_request(request): return response.redirect('/json') ``` -- `raw` - Raw response, response without encoding the body +## Raw + +Response without encoding the body ```python from sanic import response @@ -82,6 +84,7 @@ def handle_request(request): return response.raw('raw data') ``` +## Modify headers or status To modify headers or status code, pass the `headers` or `status` argument to those functions: