Course Content
Flask Intensive Course: Web Development with Python
Flask Intensive Course: Web Development with Python
URL Routing
In the previous chapter, we used the default root route, which serves as the home page when the URL is "/", and now we will explore other routing capabilities.
When you look at the URLs of everyday services, you'll notice that many of them include variable parts. Like your LinkedIn profile URL:
www.linkedin.com/<your-name>
, where your name is part of it. Flask handles these kinds of URLs using a special format in the route decorator. Here's an example that shows a route with a dynamic name part:
If we enter the http://127.0.0.1:5000/home/Joey
in your web browser URL field, you will receive:
Also, we can pass integers and other data types.
We can use any number of routes to our function. For example:
And both endpoints will return to the same page.
Thanks for your feedback!