Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Flask basic auth
- Erreur no login no password
- curl -i http://localhost:5000
- OK
- curl -i http://localhost:5000 -u "axiome:concept"
- """
- from flask import Flask
- from flask import jsonify
- from flask_httpauth import HTTPBasicAuth
- from werkzeug.security import generate_password_hash, check_password_hash
- app = Flask(__name__)
- auth = HTTPBasicAuth()
- users = {
- "axiome": generate_password_hash("concept"),
- "tony": generate_password_hash("icaro")
- }
- @auth.verify_password
- def verify_password(username, password):
- if username in users and \
- check_password_hash(users.get(username), password):
- return username
- @app.route("/")
- @auth.login_required
- def default():
- """page Web par défaut """
- return jsonify({'Base Web address':"axiome"})
- if __name__ == '__main__':
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement