# -*- 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)