You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`**kwargs` are optional and will be passed to handler directly.
111
117
**Note**: only `GET`, `POST`, `PUT`and`DELETE` methods are supported. Check [restapi full example](https://github.com/belyalov/tinyweb/blob/master/examples/rest_api.py) as well.
112
118
119
+
*`@resource`- the same idea asfor`route` but for resource:
120
+
```python
121
+
# Regular version
122
+
@app.resource('/user/<id>')
123
+
def user(data, id):
124
+
return {'id': id, 'name': 'foo'}
125
+
126
+
# Generator based / different HTTP method
127
+
@app.resource('/user/<id>', method='POST')
128
+
asyncdef user(data, id):
129
+
yield'{'
130
+
yield'"id": "{}",'.format(id)
131
+
yield'"name": "test",'
132
+
yield'}'
133
+
```
134
+
113
135
*`run(self, host="127.0.0.1", port=8081, loop_forever=True, backlog=10)`- run web server. Since *tinyweb*is fully async server by default it is blocking call assuming that you've added other tasks before.
0 commit comments