Add hyperlinks in response documentation
This commit is contained in:
parent
7d9de068d9
commit
48a26fd5df
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Use functions in `sanic.response` module to create responses.
|
Use functions in `sanic.response` module to create responses.
|
||||||
|
|
||||||
- `text` - Plain text response
|
## Plain Text
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -13,7 +13,7 @@ def handle_request(request):
|
||||||
return response.text('Hello world!')
|
return response.text('Hello world!')
|
||||||
```
|
```
|
||||||
|
|
||||||
- `html` - HTML response
|
## HTML
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -24,7 +24,7 @@ def handle_request(request):
|
||||||
return response.html('<p>Hello world!</p>')
|
return response.html('<p>Hello world!</p>')
|
||||||
```
|
```
|
||||||
|
|
||||||
- `json` - JSON response
|
## JSON
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -36,7 +36,7 @@ def handle_request(request):
|
||||||
return response.json({'message': 'Hello world!'})
|
return response.json({'message': 'Hello world!'})
|
||||||
```
|
```
|
||||||
|
|
||||||
- `file` - File response
|
## File
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -47,7 +47,7 @@ async def handle_request(request):
|
||||||
return await response.file('/srv/www/whatever.png')
|
return await response.file('/srv/www/whatever.png')
|
||||||
```
|
```
|
||||||
|
|
||||||
- `stream` - Streaming response
|
## Streaming
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -60,7 +60,7 @@ async def index(request):
|
||||||
return response.stream(streaming_fn, content_type='text/plain')
|
return response.stream(streaming_fn, content_type='text/plain')
|
||||||
```
|
```
|
||||||
|
|
||||||
- `redirect` - Redirect response
|
## Redirect
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -71,7 +71,9 @@ def handle_request(request):
|
||||||
return response.redirect('/json')
|
return response.redirect('/json')
|
||||||
```
|
```
|
||||||
|
|
||||||
- `raw` - Raw response, response without encoding the body
|
## Raw
|
||||||
|
|
||||||
|
Response without encoding the body
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from sanic import response
|
from sanic import response
|
||||||
|
@ -82,6 +84,7 @@ def handle_request(request):
|
||||||
return response.raw('raw data')
|
return response.raw('raw data')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Modify headers or status
|
||||||
|
|
||||||
To modify headers or status code, pass the `headers` or `status` argument to those functions:
|
To modify headers or status code, pass the `headers` or `status` argument to those functions:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user