Skip to content

Instantly share code, notes, and snippets.

@rlcarrca
Created August 3, 2015 01:21
Show Gist options
  • Save rlcarrca/28314abaad5eb429245e to your computer and use it in GitHub Desktop.
Save rlcarrca/28314abaad5eb429245e to your computer and use it in GitHub Desktop.
Doing basic authentication in bottle.
import bottle
def check(user, passwd):
if user == 'ben':
return True
return False
@bottle.route('/')
@bottle.auth_basic(check)
def index(location):
print 'auth', bottle.request.auth
print 'remote_addr', bottle.request.remote_addr
return "Yay - you made it!"
if __name__ == '__main__':
print "Starting server"
bottle.run(host='0.0.0.0', port=8080, reloader=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment