Create a simple to-do list app with Python Flask and Vue.js. Part 2
In the first article, we made a simple hello world application. In this post, I will show you how to add HTTP requests.
We are gonna make a simple to-do application without saving data on disk persistently. Instead, I will save data in memory. When the application restarts all data will be gone. It's ok that data is gone, cause it’s not a production-ready application. Let’s create a Python list as our database
.
Add this function get_all_todos
. This function returns the python list todos
.
So this is the first request for our application. Get all todos.
You can remove the old hello_world
function or replace it by the new function.
Take a look at the new route /todos/
.
When you hit in browser URL called /todos/
Flask understands that this should call the function named get_all_todos
. This is how routing happens. You provide a route from the server to your endpoint function
. In this case endpoint function is get_all_todos

Get one todo
Notice that route in this function is different. There’s an id with int converter. It’s a variable inside route. The function then receives the <int:id>
as a keyword argument named id
.
In our case id has an integer data type. Sometimes id can be a string or UUID. Optionally you can write:
@app.route('/todos/<id>/')
Without providing a datatype.
What does this function do?
If you write 3 it will search for todo with id 3. In the end, we return one to do.
If todo with id 3 is not found, IndexError
is raised. If IndexError
is raised we call abort
function. This function returns 404
HTTP status code. 404 — is a famous HTTP status code, which tells that the resource you’re looking for is not found.

Perfect! We’ve successfully added simple HTTP GET requests. In the following articles we will add POST and PUT methods.