Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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()
Release History

Release History

This version
History Node

0.1dev

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
WSGIProfile-0.1dev-py2.5.egg (15.0 kB) Copy SHA256 Checksum SHA256 2.5 Egg Sep 15, 2008
WSGIProfile-0.1dev.tar.gz (5.7 kB) Copy SHA256 Checksum SHA256 Source Sep 15, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting