From the course: Skill Up with Python: Hands-On Web Development Projects
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Complete and run the application - Python Tutorial
From the course: Skill Up with Python: Hands-On Web Development Projects
Complete and run the application
- All right, so now that we know how to generate shortened URLs, the next thing that we're going to need to do, of course, is when the user tries to visit that URL by sending a get request to it, presumably they would be doing that from a browser, but we'll be able to test this using Postman as well, it should redirect them to whatever the long URL was that we stored in our application. So let's go on back to our code here and what we're going to want to do is go down to this endpoint that we created a sort of a stub for. And basically all that we need to do is, since we're storing the shortened and long form URLs in this URL mappings thing, we're just going to need to look up the short URL right by this id. And well, from there what we really need to do is redirect the user, which I'll show you how to do as well. So let's get started here by just looking up that URL by the ID. So since we already have the ID as an argument here, what we need to do is we just need to say long URL…