flask 返回http code 302 404

创建日期: 2023-02-04 18:10 | 作者: 风波 | 浏览次数: 15 | 分类: Flask

返回 302

来源:https://stackoverflow.com/questions/14343812/redirecting-to-url-in-flask

import os
from flask import Flask,redirect

app = Flask(__name__)

@app.route('/')
def hello():
    return redirect("http://www.example.com", code=302)

if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)

返回 404

return render_template('404.html'), 404
15 浏览
17 爬虫
0 评论