Created
July 26, 2017 12:26
-
-
Save oz123/7e95cd76c48a16d68492383b18863239 to your computer and use it in GitHub Desktop.
basic bottle authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import Bottle, auth_basic, request, run | |
app = Bottle() | |
def check(user, passwd): | |
if user == 'oz123': | |
return True | |
return False | |
@app.route('/') | |
def user_page(): | |
return "EASY" | |
@app.route('/user/') | |
@auth_basic(check) | |
def user_page(): | |
print('auth', request.auth) | |
print('remote_addr', request.remote_addr) | |
return "Yay - you made it!" | |
if __name__ == '__main__': | |
print("Starting server") | |
run(app=app, host='0.0.0.0', port=8080, reloader=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -u oz123:xyz http://localhost:8080/user/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment