📅  最后修改于: 2022-03-11 14:55:08.732000             🧑  作者: Mango
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)