This is a Flask API that simulates a Pizza Restaurant domain.
- Create a restaurant
- Get all restaurants
- Find, update, or delete a restaurant by ID
- Create a pizza
- Get all pizzas
- Find, update, or delete a pizza by ID
- Create a new RestaurantPizza that is associated with an existing Pizza and Restaurant
git clone https://github.com/ArshavineRoy/pizza-restaurants-api
cd pizza-restaurants-api
pipenv install
-
If
pipenv
is not already installed, you can do so usingpip
:pip install pipenv
pipenv shell
python3 seed.py
python3 run.py
-
POST/restaurants
Returns JSON data for the created restaurant in the format below:
[ { "id": 1, "name": "Kilimanjaro Jamia", "address": "23 Banda Street, Nairobi" }, ]
-
GET/restaurants
Returns JSON data for restaurants in the format below:
[ { "id": 1, "name": "Dominion Pizza", "address": "Good Italian, Ngong Road, 5th Avenue" }, { "id": 2, "name": "Pizza Hut", "address": "Westgate Mall, Mwanzi Road, Nrb 100" } ]
-
GET/restaurants/:id
Returns JSON data for the requested restaurant in the format below:
{ "id": 1, "name": "Dominion Pizza", "address": "Good Italian, Ngong Road, 5th Avenue", "pizzas": [ { "id": 1, "name": "Cheese", "ingredients": "Dough, Tomato Sauce, Cheese" }, { "id": 2, "name": "Pepperoni", "ingredients": "Dough, Tomato Sauce, Cheese, Pepperoni" } ] }
-
PATCH/restaurants/:id
Returns JSON data for the updated restaurant in the format below:
-
For example:
PATCH/restaurants/1
to update address from 23 to 25 Banda Street, Nairobi.PATCH request:
[ { "name": "Kilimanjaro Jamia", "address": "231 Banda Street, Nairobi" }, ]
Response:
[ { "id": 1, "name": "Kilimanjaro Jamia", "address": "231 Banda Street, Nairobi" }, ]
-
-
DELETE /restaurants/:id
Removes a restaurant from the database along with any RestaurantPizzas that are associated with it and returns an empty dictionary.
-
POST/pizzas
Returns JSON data for the created pizza in the format below:
[ { "id": 1, "name": "BBQ chicken", "ingredients": "Dough, Cheese, chicken" }, ]
-
GET /pizzas
Return JSON data for pizzas in the format below:
[ { "id": 1, "name": "Hawaiian", "ingredients": "Dough, Tomato Sauce, Cheese" }, { "id": 2, "name": "Pepperoni", "ingredients": "Dough, Tomato Sauce, Cheese, Pepperoni" } ]
-
GET/pizzas/:id
Returns JSON data for the requested pizza in the format below:
[ { "id": 1, "name": "BBQ chicken", "ingredients": "Dough, Cheese, chicken" }, ]
-
PATCH/pizzas/:id
Returns JSON data for the updated pizza in the format below:
-
For example:
PATCH/pizzas/1
to addtomato sauce
ingredient.PATCH request:
[ { "name": "BBQ chicken", "ingredients": "Dough, Cheese, chicken, tomato sauce" }, ]
Response:
[ { "id": 1, "name": "BBQ chicken", "ingredients": "Dough, Cheese, chicken, tomato sauce" }, ]
-
-
DELETE /pizza/:id
Removes a pizza from the database along with any Restaurants or RestaurantPizzas that are associated with it and returns an empty dictionary.
-
POST /restaurant_pizzas
Creates a new RestaurantPizza that is associated with an existing Pizza and Restaurant and returns JSON data for the pizza in the format below:
[ { "id": 10, "name": "Hawaiian", "ingredients": "Dough, Tomato Sauce, Cheese" } ]
Authored by Arshavine Waema.
Licensed under the MIT License - see the LICENSE file for details.