Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
101 views
in Technique[技术] by (71.8m points)

python - Return from post-request with parameters in URL

@app.route('/path', methods= ['POST', 'GET'])
def path():
    results = getResults(request)
    return render_template('path_result.html', results=results)

I need a way to update the URL. Currently, when the user submits their form, the results are returned and rendered, but the URL does not contain the submitted page parameters. So the url remains as /path, instead of /path?formDataA=foo

Mainly I need this to allow users to share the links to specific results with one another easily.

question from:https://stackoverflow.com/questions/66067530/return-from-post-request-with-parameters-in-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you POST your data to a route you can't see the parameter. Thats the normal way. You can send your form as GET then all form parameters are appended to your url but i would prefer the POST way.

After posting the values you can redirect to another route where you display your values. When redirecting you can append some parameters your url that you need.

So make a method that process your form data. After processing redirect to another page where you display that values.

https://laravel.com/docs/8.x/routing#redirect-routes


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...