fix for docs&tests

This commit is contained in:
Anton Zhyrnyi
2017-03-14 20:53:58 +02:00
parent 85f27320e7
commit 410f86c960
2 changed files with 22 additions and 4 deletions

View File

@@ -48,6 +48,24 @@ app.add_route(SimpleView.as_view(), '/')
```
You can also use `async` syntax.
```python
from sanic import Sanic
from sanic.views import HTTPMethodView
from sanic.response import text
app = Sanic('some_name')
class SimpleAsyncView(HTTPMethodView):
async def get(self, request):
return text('I am async get method')
app.add_route(SimpleAsyncView.as_view(), '/')
```
## URL parameters
If you need any URL parameters, as discussed in the routing guide, include them
@@ -128,4 +146,4 @@ view.add(['POST', 'PUT'], lambda request: text('I am a post/put method'))
app.add_route(view, '/')
```
Note: currently you cannot build a URL for a CompositionView using `url_for`.
Note: currently you cannot build a URL for a CompositionView using `url_for`.