Advertisement
Guest User

Untitled

a guest
Mar 31st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # app.py
  2. from flask import Flask, request, redirect, url_for, make_response
  3. app = Flask(__name__)
  4.  
  5.  
  6. @app.route('/hello')
  7. def hello():
  8.     return 'Hello!'
  9.  
  10.  
  11. @app.route('/login', methods=['GET', 'POST'])
  12. def login():
  13.     if request.authorization and request.authorization.username == 'TRAIN' and request.authorization.password == 'TuN3L':
  14.         return redirect(url_for('hello'))
  15.  
  16.     return make_response('Could not verify!', 401, {'WWW-Authenticate' : 'Basic realm="Login Required'})
  17.  
  18.  
  19.  
  20.  
  21. if __name__ == '__main__':
  22.     app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement