Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created May 26, 2016 21:45
Show Gist options
  • Save seanbehan/8fa65637ca3ab850d10911edcba4b608 to your computer and use it in GitHub Desktop.
Save seanbehan/8fa65637ca3ab850d10911edcba4b608 to your computer and use it in GitHub Desktop.
using basic auth in flask
Flask Basic Auth
@app.before_request
def basic_auth():
auth = request.authorization
if not auth or (auth.username != 'username' and auth.password != 'password'):
return response('Authentication required.', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment