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)