📜  同一应用程序路由的不同功能 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:08.732000             🧑  作者: Mango

代码示例1
from flask import Flask, request, make_response

app = Flask(__name__)

@app.route('/')
def index():
    if request.authorization.username == 'user1' and request.authorization.password == 'pass1':
        index2() # you can return index2() if that's the logged in page.
        return '

You are logged in

' return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm="Login Required"'}) def index2(): print('In Index2') if __name__ == '__main__': app.run(debug=True)