From the course: Python: Decorators

Unlock the full course today

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

The route function in Flask

The route function in Flask - Python Tutorial

From the course: Python: Decorators

Start my 1-month free trial

The route function in Flask

- [Instructor] So let's look at routes in a bit more detail because that's where the decorator function is, so if we want to add another page besides the one that we just created, we could create a page and the associated Python function. So let's create a Python function called, list_fib, which just has the first couple of Fibonacci numbers and just to make things more interesting let's list these numbers as HTML bold. So I create my Python function called, list_fib and I want to return these in bold text. One, one, two, three, five, eight, 13, 21 and so on. And now let's add a route to this function and let's just call it fib. So this means that if we enter fib after the root directory in our browser we expect to get a list of the first few Fibonacci numbers, So I add my app.route decorator, so and I provide as an argument /fib. So I'm going to save my file, I'm going to go head and cancel my web server, so that's…

Contents