If someone was creating a website that lists all the cafes, then they would need to fetch all the cafes in our database.
e.g. https://laptopfriendly.co/london
CHALLENGE:
1. Create another GET route that's called /all
2. When a GET request is made to this /all route, your server should return all the cafes in your database as a JSON.
e.g.
https://gist.github.com/angelabauer/889a0e57359ede23e7b09a7902a45a6e
Hint: Combine the .execute()
and .select()
methods to make the query using flask-sqlalchemy. Don't forget to convert your result into a Python list with .scalars()
.