如何使用tornado的asynch httpclient调用在本地主机上运行的api

时间:2017-04-15 09:52:06

标签: api asynchronous tornado

class ApiHandler(RequestHandler):
    @asynchronous
    def get(self):
        client = AsyncHTTPClient()
        client.fetch("https://localhost:9999/leaderboard",
                     callback=self.on_response)

    def on_response(self, response):
        body = response.body
        self.write(json.load(body))
        self.finish()

0 个答案:

没有答案