![](/img/trans.png)
[英]Is there a way to change the root URL in python's Tornado web framework?
[英]Issue in Passing URL in python tornado framework
我正在传递资源路径,如下所示。
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.