| 1 | --- |
| 2 | title: WSGI |
| 3 | weight: 2 |
| 4 | --- |
| 5 | |
| 6 | To use Prometheus with [WSGI](http://wsgi.readthedocs.org/en/latest/), there is |
| 7 | `make_wsgi_app` which creates a WSGI application. |
| 8 | |
| 9 | ```python |
| 10 | from prometheus_client import make_wsgi_app |
| 11 | from wsgiref.simple_server import make_server |
| 12 | |
| 13 | app = make_wsgi_app() |
| 14 | httpd = make_server('', 8000, app) |
| 15 | httpd.serve_forever() |
| 16 | ``` |
| 17 | |
| 18 | Such an application can be useful when integrating Prometheus metrics with WSGI |
| 19 | apps. |
| 20 | |
| 21 | The method `start_wsgi_server` can be used to serve the metrics through the |
| 22 | WSGI reference implementation in a new thread. |
| 23 | |
| 24 | ```python |
| 25 | from prometheus_client import start_wsgi_server |
| 26 | |
| 27 | start_wsgi_server(8000) |
| 28 | ``` |
| 29 | |
| 30 | By default, the WSGI application will respect `Accept-Encoding:gzip` headers used by Prometheus |
| 31 | and compress the response if such a header is present. This behaviour can be disabled by passing |
| 32 | `disable_compression=True` when creating the app, like this: |
| 33 | |
| 34 | ```python |
| 35 | app = make_wsgi_app(disable_compression=True) |
| 36 | ``` |