Skip to content

Instantly share code, notes, and snippets.

@neotyk
Last active August 29, 2015 13:56
Show Gist options
  • Save neotyk/8934930 to your computer and use it in GitHub Desktop.
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.
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