天天看點

tornado傳回指定的http code

最近做web api,需要在接口傳回異常時,傳回對應的http code。

查了下tornado的文檔,是通過set_status方法來設定傳回的http code,做個記錄。

self.set_status(200)
self.write(json)