Last active
August 29, 2015 13:56
-
-
Save neotyk/8934930 to your computer and use it in GitHub Desktop.
Initialize New Relic before including bottle to avoid naming problem when bottle.auth_basic is used.
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
import newrelic.agent | |
newrelic.agent.initialize('newrelic.ini') | |
from bottle import route, run, template, app, auth_basic | |
@route('/public') | |
def public(): | |
return 'something something' | |
@route('/hello/:name') | |
def index(name): | |
return template('<b>Hello {{name}}</b>!', name=name) | |
def check(u,p): | |
return u == "bob" and p == "bob" | |
@route('/private') | |
@auth_basic(check) | |
def private_handler(): | |
return 'you\'ve found a secret' | |
run(host='localhost', port=8080, app=newrelic.agent.WSGIApplicationWrapper(app())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment