From the course: Flask Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Passing form variables to other routes in Flask

Passing form variables to other routes in Flask

From the course: Flask Essential Training

Start my 1-month free trial

Passing form variables to other routes in Flask

- [Instructor] So currently with our app, if we try and shorten some sort of URL, we're left with a Not Found page, and that's because our form head says to go to this URL called your-url, but we haven't created the route for it. So, let's go ahead and move back into our code here. And currently, we have this about page, but we don't really need it. So let's go ahead and transform this into our your-url page. So I'm going to change this from /about to your-url. Also, I want to change the name of the function from about to your_url. Now the reason I've used an underscore rather than a dash is that Python functions don't allow for a dash. So I want to keep that as an underscore. And instead of just returning some sort of string, I'd like to bring back a template. So just like we've done for the homepage, I'm going to copy this render_template, going to paste it here and change this to a file that we will create called…

Contents