different functions for same app route
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 '<h1>You are logged in</h1>'
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)