Skip to content

Instantly share code, notes, and snippets.

@amjith
Created July 5, 2012 20:16
Show Gist options
  • Save amjith/3056191 to your computer and use it in GitHub Desktop.
Save amjith/3056191 to your computer and use it in GitHub Desktop.
Simple WSGI App
from time import sleep
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
@newrelic.agent.wsgi_application()
def hello_world(environ, start_response):
path = environ.get('PATH_INFO')
if path.startswith('/slow'):
for _ in range(9):
sleep(1)
start_response('200 OK', [('Content-Type', 'text/html')])
header = newrelic.agent.get_browser_timing_header
footer = newrelic.agent.get_browser_timing_footer
return ['<head>', header(), '</head>', '<body>Hello', footer(), '</body>']
if __name__ == '__main__':
from wsgiref.simple_server import make_server
srv = make_server('localhost', 8000, hello_world)
srv.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment