Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.23 KB

python-gunicorn.mdx

File metadata and controls

46 lines (36 loc) · 1.23 KB
title sidebarTitle description icon
Gunicorn + Subtrace
Gunicorn
Connect your Gunicorn backend to Chrome DevTools using Subtrace
python

You can connect your Gunicorn backend to Chrome DevTools using Subtrace with just one command. With Subtrace, you can inspect the status, headers, payload, and latency of all API requests so you can debug way faster.

For this guide, we'll use the following Gunicorn app as an example:

# myapp.py
def app(environ, start_response):
    data = b"Hello, World!\n"
    start_response("200 OK", [
        ("Content-Type", "text/plain"),
        ("Content-Length", str(len(data)))
    ])
    return iter([data])

To start, download the latest version of Subtrace:

curl -fsSLO "https://subtrace.dev/download/latest/$(uname -s)/$(uname -m)/subtrace"
chmod +x ./subtrace

Get a SUBTRACE_TOKEN from the Subtrace dashboard for free to set it as an environment variable.

# get a token for free at https://subtrace.dev/dashboard
export SUBTRACE_TOKEN=

To start your server on port 8000, run the following command:

./subtrace run -- gunicorn -w 4 myapp:app

Send a request to localhost:8000 to see it in the Subtrace dashboard!