How do I return HTTP error code without default template in Tornado?

后端 未结 7 2175
情深已故
情深已故 2021-02-01 02:40

I am currently using the following to raise a HTTP bad request:

raise tornado.web.HTTPError(400)

which returns a html output:

&         


        
7条回答
  •  春和景丽
    2021-02-01 03:32

    You may simulate RequestHandler.send_error method:

    class MyHandler(tornado.web.RequestHandler):
        def get(self):
            self.clear()
            self.set_status(400)
            self.finish("My custom body")
    

提交回复
热议问题