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
From the course: Flask Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Install Flask and Pipenv3m 11s
-
Create your first route in a Flask project6m 4s
-
(Locked)
Flask's development environment4m 56s
-
(Locked)
Page templates in Flask with Jinja4m 29s
-
(Locked)
Passing data into Flask apps with forms6m 11s
-
(Locked)
Passing form variables to other routes in Flask4m 20s
-
(Locked)
Using GET and POST requests in Flask3m 31s
-
-
-
-
-