Welcome to my coupons service using AWS DynamoDB light container
This service will allow u own your own amazing coupons service!
Just Enter as many coupons by domain_name, coupon_value(must be positive integer less than 100), and a coupon_code
See usage via postman at the buttom
(Make sure docker is running)
Open a shell, pull image:
- docker pull amazon/dynamodb-local
- docker images
- Additional info about amazon/dynamodb-local can be found at https://hub.docker.com/r/amazon/dynamodb-local
- docker run -p 8000:8000 amazon/dynamodb-local
- git clone https://github.com/Arielegend/couponlightdb.git
- cd couponlightdb
- python3 -m venv venv
- source venv/bin/activate
- pip install .
- (at venv) run main.py file
- Flask server should open at a local host, port 8000.
- http://127.0.0.1:8000/
Coupons service has 2 url endpoints:
- GET /GetCoupon
- Params: domain: str, value:int (lower than 100)
- POST /ReturnCoupon
- Post with body as follows:
- {'codesreturn': str, 'domainreturn': str, 'valuereturn': int}
- Post with body as follows:
- Post example:
-
{ "codesreturn":"code1 code2 code3", "domainreturn":"domainX", "valuereturn":"10" }
-
Responses examples:
response = [ "Successfully added new coupon: (code: code1), (value: 10), (domain: domainX)", "Successfully added new coupon: (code: code2), (value: 10), (domain: domainX)", "Successfully added new coupon: (code: code3), (value: 10), (domain: domainX)" ] response = [ "Coupon -- code: code1, domain: domainX -- already exists!", "Coupon -- code: code2, domain: domainX -- already exists!", "Coupon -- code: code3, domain: domainX -- already exists!" ]
- Get example:
-
http://127.0.0.1:8000/internal/GetCoupon?domain=domainAlpha&value=10
-
Responses examples :
//Coupon exists response = { 'response_code': True, 'coupon_code': 'code1' } //Coupon doesn't exists response = { 'response_code': False, 'coupon_code': 'No such coupon' }
-