python - python tornado框架中传递URL的问题
问题描述
我正在传递资源路径,如下所示。
application = tornado.web.Application(handlers=[ (r"/rsgateway/data/json/eventstore/subscriber/orderid/555555&xyz=1", getUsageHistory),)
在资源路径中,我需要传递 URL。但是由于像 +,$ 这样的特殊字符,我的脚本没有返回 output 。需要知道如何在资源路径中传递 url。
解决方案
您应该在处理程序中接收请求参数。您的代码可能如下所示:
应用程序:
application = tornado.web.Application(handlers=[
(r"/rsgateway/data/json/eventstore/subscriber/orderid/([0-9]+)", UsageHistory),
])
和处理程序:
class UsageHistory(RequestHandler):
async def get(self, order_id: str):
xyz = self.request.query_arguments.get('xyz')
data = await self.orders.get_history(int(order_id), xyz)
await self.finish(escape.json_encode(data))
推荐阅读
- c++ - 为什么 WS_TABSTOP 不适用于富编辑控件?
- angular - 如何从带有mat-slider属性的displaywith属性中获取组件的值
- javascript - React 组件列表返回 D3 SVG 与列表中的第一个图像相同的图像
- konvajs - Konvajs 自定义形状和转换器
- python - 如何强制 Flask 更改版本?(即使在指定 1.0.2 后报告 0.12.2)
- c++ - 如何从核心转储文件中识别导致崩溃的完整命令
- javascript - 完整日历:使用 IF 语句为事件着色
- vuejs2 - Vuejs 用于创建带有是/否嵌套问题的动态调查表
- javascript - html 对象不显示它应该在移动设备上的位置
- python - 根据字典值计算numpy数组中向量的总和