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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file WSGIProfile-0.1dev.tar.gz.
File metadata
- Download URL: WSGIProfile-0.1dev.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa34cc21f0f8ac0a6d554e497363d80689ec8e4bdeb308e3968667bc6f357c33
|
|
| MD5 |
0eb6f08b0537ff6e038b4c36748f063b
|
|
| BLAKE2b-256 |
c213532e418c0a145b244a9b5453101fc58ff26e94a3aaabf838f3dc72ff3a03
|
File details
Details for the file WSGIProfile-0.1dev-py2.5.egg.
File metadata
- Download URL: WSGIProfile-0.1dev-py2.5.egg
- Upload date:
- Size: 15.0 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1c16d621f0df56fbf614fe2ccf16c700af662ce57aa46533d2dcdffcef8e5e
|
|
| MD5 |
2fce7d2eb7ea70e684bcb28a1bc71b35
|
|
| BLAKE2b-256 |
9309e21d9ddc3f10abb72fcdc0fff7bb3cedc889ce3d5fbee3d7b37c382aef09
|