This is a simple API created with Python and Flask.
This API use GET and POST methods for differents routes.
GET
POST
Any other query to an incorrect route will be display an error message like this
{
"error": "Not found"
}
Running on Docker
$ docker run -d --name api-test -p 3000:3000 conejado/api-test
Running on Kubernetes
$ git clone https://github.com/coneking/api-test.git
$ kubectl apply -f api-test/k8s
If you running on Kubernetes use the ingress resource or expose the service api-test with port-forward.
$ kubectl port-forward svc/api-test 3000
Forwarding from 127.0.0.1:3000 -> 3000
Forwarding from [::1]:3000 -> 3000
Now you can consume the api as shown below.
The first path (server-status) show the json message {"status": "running"}.
$ curl http://0.0.0.0:3000/api/v1/server/server-status
{
"status": "running"
}
The second path (timeout) will be display a json message after 3 minutes to simulate a 504 time-out error
$ curl http://0.0.0.0:3000/api/v1/server/timeout
{
"time": "So slow... more than 3 minutes"
}
The following path will return the message sent in json format.
$ curl -X POST -d '{"Species": {"name": "Charmander", "ID": "4"}, "Type": {"name": "fire"}}' -H "Content-Type: application/json" http://0.0.0.0:3000/api/v1/test/post-test
{
"Species": {
"ID": "4",
"name": "Charmander"
},
"Type": {
"name": "fire"
}
}
Content type
Image
Digest
Size
46.3 MB
Last updated
over 4 years ago
docker pull conejado/api-test