Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
URL Routing | Introduction to Flask
Flask Intensive Course: Web Development with Python

URL RoutingURL 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.

1. What type of variable should be used in the route when expecting an integer as part of the URL path?
2. In Flask, how many unique routes can be created using the following route decorators?
3. Which HTTP methods can be used in a Flask route by default?

What type of variable should be used in the route when expecting an integer as part of the URL path?

Виберіть правильну відповідь

In Flask, how many unique routes can be created using the following route decorators?

Виберіть правильну відповідь

Which HTTP methods can be used in a Flask route by default?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 1. Розділ 4
course content

Зміст курсу

Flask Intensive Course: Web Development with Python

URL RoutingURL 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.

1. What type of variable should be used in the route when expecting an integer as part of the URL path?
2. In Flask, how many unique routes can be created using the following route decorators?
3. Which HTTP methods can be used in a Flask route by default?

What type of variable should be used in the route when expecting an integer as part of the URL path?

Виберіть правильну відповідь

In Flask, how many unique routes can be created using the following route decorators?

Виберіть правильну відповідь

Which HTTP methods can be used in a Flask route by default?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 1. Розділ 4
some-alt