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

后端 未结 7 2143
情深已故
情深已故 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:24

    Also you can override get_error_html method in your handler. For example:

    import tornado.web
    class CustomHandler(tornado.web.RequestHandler):
        def get_error_html(self, status_code, **kwargs);
            self.write("

    404!

    ") ... def get(self): ...

提交回复
热议问题