DEV Community

Cover image for Log Connexion request body
Kevin Martins
Kevin Martins

Posted on • Originally published at kevinmmartins.Medium

Log Connexion request body

Connexion is a framework on top of Flask that automagically handles HTTP requests defined using OpenAPI

Connexion it’s an amazing framework but logging in the request body may not be such an easy task.

To log Connexion request body just add the following code:

import connexion
from flask import request

app = connexion.App(__name__, specification_dir="./swagger/")


@app.app.before_request
def log_request_info():
    print('Body: %s', request.get_data())
    logger.info('Body: %s', request.get_data())
Enter fullscreen mode Exit fullscreen mode

Hope this helps !

Top comments (0)