Created
July 5, 2012 20:16
-
-
Save amjith/3056191 to your computer and use it in GitHub Desktop.
Simple WSGI App
This file contains 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
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