wos*_*oss 4 python query-string falconframework
您如何将应用程序配置为具有以下功能:
将api端点定义为 app.add_route('/v1/tablets', TabletsCollection())
而且仍然可以像这样使用QueryParams https://example.com/api/v1/tablets?limit=12&offset=50&q=tablet name
集合有两种方法on_get来检索整个列表并使用过滤器和on_post创建单个记录。
我已经在网上搜索了一段时间,如何获得query_string和正确解析的参数?
猎鹰传递给您的API端点的Request对象上都可以使用查询字符串和已解析的查询字符串(作为字典)。
您的处理程序可以执行以下操作:
class TabletsCollection():
def on_post(self, req, resp):
print req.query_string
for key, value in req.params.items():
print key, value
Run Code Online (Sandbox Code Playgroud)
请参阅http://falcon.readthedocs.io/en/stable/api/request_and_response.html#Request.query_string和http://falcon.readthedocs.io/en/stable/api/request_and_response.html#Request.params。
| 归档时间: |
|
| 查看次数: |
4589 次 |
| 最近记录: |