WSGI Middleware for embedding a rich profiler in web pages.
Project description
First install WSGIProfile. You may also need to install the python-profiler package if you are on Ubuntu.
easy_install WSGIProfile sudo apt-get install python-profiler
Next lets create a very simple WSGI application with one slow function:
import time def app(environ, start_response): time.sleep(2) start_response('200 OK', [('Content-Type', 'text/html')]) return ['Hello World!'] if __name__ == '__main__': from wsgiref.simple_server import make_server server = make_server('127.0.0.1', 8080, app) server.serve_forever()
Point your browser at http://localhost:8080 and you should see “Hello World!”.
Adding profiling information to this application is as simple as wrapping the application function in some profiling middleware:
app = ProfileMiddleware(app)
Our example now looks like this:
import time def app(environ, start_response): time.sleep(2) start_response('200 OK', [('Content-Type', 'text/html')]) return ['Hello World!'] if __name__ == '__main__': from wsgiref.simple_server import make_server from wsgiprofile import ProfileMiddleware app = ProfileMiddleware(app) server = make_server('127.0.0.1', 8080, app) server.serve_forever()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
WSGIProfile-0.1dev.tar.gz
(5.7 kB
view hashes)
Built Distribution
WSGIProfile-0.1dev-py2.5.egg
(15.0 kB
view hashes)