DEV Community

Josua Schmid
Josua Schmid

Posted on

Incercept HTTP for logs

If you need a fast way to intercept HTTP requests for debugging, you can use pyserv. It's a one-class python library which simply logs inbound HTTP requests.

pip install pyserv
serv 8001

# in another terminal:
curl -X POST "http://localhost:8001/blub/lol" -H "accept: */*" -H "Content-Type: application/json" -d "[{\"yay\": \"data\"}]"
Enter fullscreen mode Exit fullscreen mode
INFO:root:Starting HTTP SERVER at PORT 8001
INFO:root:POST  request,
Path: /blub/lol
Headers:
Host: localhost:8001
User-Agent: curl/7.54.0
accept: */*
Content-Type: application/json
Content-Length: 17



Body:
[{"yay": "data"}]

127.0.0.1 - - [03/Feb/2021 14:07:27] "POST /blub/lol HTTP/1.1" 200 -
Enter fullscreen mode Exit fullscreen mode

Top comments (0)