flask 重定向详解

from flask import Flask,request,redirect,url_for


app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'hello world'


@app.route('/login/')
def login():
    return 'login'


@app.route('/user_profile/')
def profile():
    if request.args.get('name'):
        return '个人中心页面'
    return redirect(url_for('login'),code=302)


if __name__ == '__main__':
    app.run(debug=True)

猜你喜欢

转载自www.cnblogs.com/wuheng-123/p/9667524.html