簡體   English   中英

在 python 龍卷風框架中傳遞 URL 的問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM