This is a template to implement a RESTful API using Python.
It is based on Flask framework.
There is one resource, called "resource" and supporting four verbs: GET, POST, PUT and DELETE.
The template features also a Docker image in order to deploy the API in a container.
Here you can find a good tutorial on how to implement REST API in Python with Flask.
The root route provides this documentation:
GET {{url}}/
Then we have the route to access the "resource" resource:
GET {{url}}/resource/{{resource-id}}
POST {{url}}/resource
body:
{
"field": "resource-field"
}
PUT {{url}}/resource/{{resource-id}}
body:
{
"field": "resource-field-modification"
}
DELETE {{url}}/resource/{{resource-id}}
body:
{
"field": "resource-field-modification"
}
pip install -r requirements.txt
python src/test.py
python src/server.py
docker image build -t rest-api-template .
docker container run -p 5000:5000 -d rest-api-template