2.3 请求头重定向
# 视图函数和普通函数的区别 # 1、视图函数还返回status code 状态码(200,404,301); # 2、返回http headers属性的content-type状态,作用告诉接收方如何解析返回的主体内容;默认='text/html','application/json' # 2、当视图函数返回是字符串时,系统会默认返回“Response”对象。可以定义此对象返回。 # 定义视图函数 @app.route('/hello/') def hello(): headers = { 'content-type': 'application/json' 'location'=='http://www.baidu.com' } # response = make_response('<html></html>',301) # response.headers = headers return '<html></html>',301,headers
浙公网安备 33010602011771号