frol / flask-restplus-server-example

Real-life RESTful server example on Flask-RESTplus

Home Page:http://flask-restplus-example-server.herokuapp.com/api/v1/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Analyze the request and response json

luisdemarchi opened this issue · comments

How do I print to the terminal to parse the body of the request and the response?

PS: before I even got into scheme

It is unclear to me what you want to achieve. Use standard logging module to log anything you want.

@frol I need to see the body of the requisition, before arriving at my method POST. How do I do that?

A simulation of what I need:

    @api.parameters(parameters.RequestParameters())
    @api.response(schemas.ResponseSchema())
    @api.response(code=HTTPStatus.UNAUTHORIZED)
    @api.response(code=HTTPStatus.UNPROCESSABLE_ENTITY)
    def post(self, args):
        req_data = self.request.get_json(force=True)
        print(req_data)

You can use standard Flask methods:

from flask import request

def post(...):
    print(request)

http://flask.pocoo.org/docs/1.0/api/#flask.Request