0

I have a Flask Application that is prototyped as below and I want to be able to resend some requests received in one or more endpoints.

I would like to store the information necessary to send the request in the rawest state so it can be re-sent with the same path, url method, headers and body.

app = Flask(__name__)

old_requests = []

@app.route("/hello", methods=["GET", "POST", "PUT", "DELETE"])
def hello():

    ## Do something with request data here

    old_requests.append(
        ## some information about the request that will allow to re-send it
    )

    return "Ok", 200


@app.route("/resend/<int:request_index>", methods=["GET"])
def resend_request(request_index):
    request_info = old_requests[request_index]

    ## use this info to re-send the request, with the same headers and body
    return "Ok", 200

What would be an abstract and pythonic way to do that?

In the code above I am storing the requests' information in an array, but of course in the real problem it is a database.

Jundiaius
  • 3,537
  • 2
  • 20
  • 32

0 Answers0