I am relatively new to Python so please excuse any naive questions.
I have a home page with 2 inputs, one for a "product" and one for an "email." When a user clicks submit they should be sent to "/success" where it will say: You have requested "product" You will be notified at "email"
I am trying to figure out the best way to pass the "product" and "email" values through the redirect into my "/success" template. I am using webapp2 framework and jinja within Google App Enginge.
Thanks
Click Action > URL Redirect. Give your action an internal title (something that makes sense to you in the survey). Enter the link to the site in the URL field. Scroll to the Fields To Pass and select the question, hidden value, or URL Variables you would like to pass in the Question to Send dropdown.
To pass arguments into redirect(url_for()) of Flask, we define the destination route to get the request parameters. Then we can call url_for with the parameters. to add the /found/<email>/<list_of_objects> route that maps to the found function. In it, we get the the URL parameters from the found function's parameters.
redirect returns a 302 header to the browser, with its Location header as the URL for the index function. render_template returns a 200, with the index. html template returned as the content at that URL.
Under normal usage the standard is to use URL (GET) variables when you are retrieving data from the server and to use Form (POST) variables when you want to manipulate (edit/delete) data on the server.
When you do your redirect, include your email and product variables in the redirect. In Google appp engine, using webapp2, your current redirect probably looks like:
self.redirect('/sucess')
Instead, you can add the variables in the URL as follows:
self.redirect('/success?email=' + email + '&product=' + product)
The above URL would look like '/[email protected]&product=this_product' after concatenating the values.
The handler for /success could then get those values with:
email = self.request.get('email')
product = self.request.get('product')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With