The api.py file have a simple code for API Restful with the Flask package. Then, before run the API, do you need install the Python 3, and the Flask package with pip.
sudo apt install python3
sudo apt install python3-pip
pip3 install Flask
pip3 install Flask-RESTfulAfter install the Python and Flask, do you can run the api.py file and after this, in your browser go to URL http://localhost:5000/api.
The GET method use for get information, in line 17, the method GET return the datas about the ID informated in request query string.
def get(self):
return {
'name': 'Mateus Oliveira',
'escola': "IFRN/Par",
'orientador': "Jurandy",
'curso': 'Informática',
'email': 'matews5522@gmail.com',
'phone': '084998177501',
}For example:
go to URL: http://localhost:5000/api?id=1. And a JSON object is returned for you with the informations for the user with ID 1.
In this simple code, I didn't use data bases, because I did show the API and her methods for a frontend applications use the API. But if you will implement a data bases, I recommend the NoSQL Data Bases MongoDB, and you can use the MongoDB in Python with the PyMongo package.