Tags | flask django sqlalchemy |
Hard Prerequisites | |
IMPORTANT: Please review these prerequisites, they include important information that will help you with this content. | |
|
In this project you’ll be taking a lot of your existing knowledge and putting it together. At this point you know what it means to consume an API, now you’re going to make one.
The tools to use:
Please note, people have been making APIs for a loooong time now. So there are loads of cool and useful tools out there that make this kind of thing quick and easy. With that said, it’s super important that you know how to make one from scratch on your own instead of just using someone else’s stuff.
What you need is a profound appreciation for what an API is and how it works.
Firstly, Flask is simple compared to Django. So, you can jump right in and learn the API lessons we are trying to teach here. The lessons you learn in Flask are easily transferrable, if you do get into Django later on, then you’ll have a good understanding of its foundations by default.
Create a Flask app that exposes a REST API for keeping track of computers owned by Umuzi.
Just make one table in your database: Computer.
For every computer we’ll need to know:
Note that some of the fields can only allow certain values. This is often called enumeration.
Expose some REST api endpoints, the content type must be json.
The following operations should be allowed (and should be exposed at well named urls):
Just do it Okuur? Don’t forget best practice now.
Umuzi is growing pretty fast. So that means we keep having to buy computers. Eventually when you call the list computers endpoint the list will be way too long.
To combat this, there is a technique called paging.
Implement that :)