REST API server to rank your most preferred pasta recipes.
You can vote for the following pasta recipes:
cacio e pepe
carbonara
ragù alla bolognese
spaghetti pomodoro e basilico
pasta al pesto
amatriciana
pasta fredda
Use the following endpoints to know what are the most voted pasta recipes:
/vote
POST: vote for your pasta recipe! Upload a JSON message containing therecipe
as a key/recipe/<recipe>
GET: retrieve the votes of pastarecipe
/recipes
GET: retrieve all the voted pasta recipes and see their votes/rank
GET: get the rank of all pasta recipes!/clean
GET: delete all votes
All votes will be stored in a votes.txt
JSON file in the root directory.
The access to the file is handled by a threading.Lock()
resource:
{
"cacio e pepe": 4,
"carbonara": 2
}
A file.log
log file will be created in the root directory:
2021-02-17 20:01:28,609 - pastastore.logger - INFO - /vote {'recipe': 'carbonara'}
2021-02-17 20:01:28,609 - pastastore.logger - INFO - carbonara has been added 200
2021-02-17 20:01:30,730 - pastastore.logger - INFO - /vote {'recipe': 'cacio e pepe'}
2021-02-17 20:01:30,731 - pastastore.logger - INFO - cacio e pepe has been added 200
2021-02-17 20:01:32,720 - pastastore.logger - INFO - /recipes
2021-02-17 20:01:32,720 - pastastore.logger - INFO - {'carbonara': 1, 'cacio e pepe': 1} 200
2021-02-17 20:01:35,111 - pastastore.logger - INFO - /rank
2021-02-17 20:01:35,111 - pastastore.logger - INFO - {1: {'recipe': 'cacio e pepe', 'votes': 1}, 2: {'recipe': 'carbonara', 'votes': 1}} 200
2021-02-17 20:01:37,532 - pastastore.logger - INFO - /recipe cacio e pepe
2021-02-17 20:01:37,532 - pastastore.logger - INFO - 1 200
2021-02-17 20:01:39,438 - pastastore.logger - INFO - /clean
2021-02-17 20:01:39,439 - pastastore.logger - INFO - Cleaned 200