A part of a mini shopping app.
Python 3.8+ must be installed.
Navigate to project folder in CLI, and use
pip install -r requirements.txt
Run the service by typing
python app.py
Build the project using
docker build -t [tagname] .
Run the service using
docker run -p 5000:[port] [tagname]
where [port] could be 5000. In that case, the service will be available on //localhost:5000
[*] title: str
description: str
[*] price: int
currency: str
[*] orders: [Order]
total: float
amount: int
[*] product_id: int
*: required
POST /product
Input:
Product
Example:
{
"title": "Computeractic",
"description": "didactic",
"price": "17",
"currency": "USD"
}
Response:
200 OK
product_id: int
GET /product/:id
Parameters
id: int
Response:
product_id: int
title: str
description: str
price: float
currency: str
stock: int
GET /product
Response:
200 OK
products: [Product]
DELETE /product/:id
Parameters
id: int
POST /cart
Input:
Cart
Response:
200 OK
cart_id: int
total: float
GET /cart/:id
Parameters
id: int
POST /cart/:id/add
Rules:
- Every fifth item free
- Maximum 100 usd total
- Discount of 1 usd above 20
Rule violation results in Error (see Error_msg for details).
Parameters
id: int
Input:
Order
Results:
204 OK
[No Body]
400 Error
{"Error": Error_msg}
POST /cart/:id/orders
Parameters
id: int