我正在用Python编写一个控制器端点,我想修改响应代码,内容文本等。如何实现它。
@http.route('/get/data/',methods=['GET','POST'],type="http",auth='public',csrf=False)
def fetchSms(self,**kwargs):
mydata = {"date":"2018-10-13T00:46:17.25Z"}
return simplejson.dumps(mydata)
设置content-type =“ application / json”后,我必须将mydata返回给客户端,并且响应响应代码应为200
当前输出:
HTTP / 1.1 200确定
服务器:nginx / 1.12.2
日期:2018年10月15日星期一16:57:49 GMT
Content-Type:文本/ html; charset = utf-8
内容长度:192
连接:保持活动状态
Set-Cookie:session_id = 43edf5hfgh436sdgdga9d7618deb74af7; Expires = Sun,13-Jan-2019 16:57:49 GMT;最大年龄= 7776000;路径= /