Skip to content

Instantly share code, notes, and snippets.

@yubessy
Last active Aug 29, 2015
Embed
What would you like to do?
PythonのbottleでBASIC認証 ref: http://qiita.com/yubessy/items/33789eccb35b659b0b4e
$ python hello.py
# -*- coding: utf-8 -*-
import bottle
# BASIC認証のユーザ名とパスワード
USERNAME = "user"
PASSWORD = "pass"
def check(username, password):
u"""
BASIC認証のユーザ名とパスワードをチェック
@bottle.auth_basic(check)で適用
"""
return username == USERNAME and password == PASSWORD
@bottle.route("/hello")
@bottle.auth_basic(check)
def hello():
return "hello"
if __name__ == '__main__':
bottle.run(host='localhost', port=8080, debug=True)
python hello.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment