This is a simple API example using Flask and Redis.
It's dead simple: type docker-compose up
, wait for it to complete and hit some
of the endpoints listed below.
Note that the hostname may change depending on how you installed Docker. If you
have installed Docker Toolbox (in case you're running Windows 10 Home, for
example), hostname will be the IP returned by docker-machine ip
command,
otherwise it will be "localhost".
The port remains the same (5000) no matter which installation you have made.
Creates a cart. No body required. Example response:
[]
Adds a product to the cart. Example post body:
{
"product_id": 456
}
Example response:
[
123,
456
]
Gets the cart. Example response:
[
123,
456
]
Deletes product from the cart. Example response:
[
456
]
Deletes the cart. Example response:
true
You can easily test all endpoints importing postman_collection.json
in
Postman. Hostname (including port) is isolated in a variable, so you can change
it for all requests if needed.