How to generate a flask.request form and pass via redirect to post page

Viewed 14

I have a page where based on submitted form it returns some results to the client. Now I want to reuse this route and make a prefilled submit for the user when he is redircted from some other route.

So the redirect happens like this (307 for allowing post method):

return redirect(url_for('e_blueprint.planned_places_search',
            latitude='', longitude='', code=307)

I am passing url parameters and can receive them fine in the redirected url:

@e_blueprint.route("/search/", methods=['POST', 'GET'])
def planned_places_search()-> json:
        if request.method == "POST":

            #getting url parameters work fine:
            username = request.args.get('latitude')
            password = request.args.get('longitude')

            # !!! but i am already using request.form for same variables on the route
            latitude = request.form['latitude']
            longitude = request.form['longitude']

Can I make a request.form before redirect on the backend (values are known) and then pass it to that redirected page?

0 Answers
Related