This is a simple project that creates a RESTful API for pizza-restaurants database. The database contains three tables:
- A
Restaurant
has manyPizzas
throughRestaurantPizza
- A
Pizza
has manyRestaurants
throughRestaurantPizza
- A
RestaurantPizza
belongs to a Restaurant and belongs to aPizza
git clone https://github.com/JOY19ANYANGO/pizza-restaurants-code-challenge.git
cd pizza-restaurants-code-challenge
The root directory of this repository contains the Pipfile
with all the required Python libraries for this project and restricts them to this repository.
To install the required libraries, run:
pipenv install
pipenv shell
cd server ; python3 app.py
- Run
python3 seed.py
to populate database.
The REST API allows various HTTP methods:
- Retrieve records of all restaurants.
- Retrieve one restaurant.
- Delete a restaurant.
- Retrieve records of all pizzas.
- Create a new restaurant_pizza.
To retrieve records of all restaurants navigate to the following URL:http://127.0.0.1:5555/restaurants
To retrieve one restaurant use the following URL:http://127.0.0.1:5555/restaurants/:id
.Replace id with the actual id of the restaurant
We can delete a restaurant using postman.
- Enter the following URL:
http://127.0.0.1:5555/restaurants/:id
.Replace id with the actual id of the restaurant - Select the DELETE method and press send.
To retrieve records of all restaurants navigate to the following URL:http://127.0.0.1:5555/pizzas
We can delete a restaurant using postman.
- Enter the following URL:
http://127.0.0.1:5555/restaurant_pizzas
- Select the POST method.
- In the request body enter the following.
{
"price": 5,
"pizza_id": 1,
"restaurant_id": 3
}
- Press send
Authored by Joy Anyango.
Licensed under the MIT