I have created a proxy to test my microservices locally with Flask. I need to redirect requests with POST data dynamically, meaning my proxy has to forward the POST data without knowing the name of the parameters. My code looks something like this
@app.route('/', defaults={'path': ''}, methods=HTTP_METHODS)
@app.route('/<path:path>', methods=HTTP_METHODS)
def redirect_request(path):
for i in routes:
if i[0] == '/' + path:
if flask.request.method == 'POST':
return flask.redirect(i[1] + i[0], code=307)
return flask.redirect(i[1] + i[0])
return flask.Response('not ok')
I tried to pass flask.request.form as **kwargs in flask.redirect(), but it doesn't work. Any idea how I can do it?