Вывод HTTP ответов при отладке

This commit is contained in:
Lev 2022-11-27 18:38:10 +07:00
parent 8be3fc137a
commit b55cb01fba
No known key found for this signature in database
GPG key ID: 21C6C2C9C0A4460D

View file

@ -245,8 +245,10 @@ if __name__ == '__main__':
logging.basicConfig(format='%(levelname)s -> %(message)s', level=args.log_level.upper())
def response_hook(resp, *_args, **_kwargs):
if logging.root.isEnabledFor(logging.DEBUG):
if 'application/json' in resp.headers['Content-Type']:
logging.debug(resp.text)
time.sleep(args.delay)
pass
session = Session()
session.hooks = {'response': response_hook}