Python-Flask-重定向
from flask import Flask
from flask import redirect
from flask import url_for
app = Flask(__name__)
@app.route('/')
def index():
return 'hello'
# @app.route('/redirect')
# def deom1():
# return redirect('http://www.baidu.com')
@app.route("/demo2/<int:user_id>")
def demo2(user_id):
return "重定向 %s" % user_id
@app.route('/itt')
def demo1():
return redirect(url_for('demo2', user_id=123))
if __name__ == '__main__':
app.run()