Git Product home page Git Product logo

pizza-restaurants-code-challenge's Introduction

pizza-restaurants-code-challenge

This is a simple project that creates a RESTful API for pizza-restaurants database. The database contains three tables:

  • A Restaurant has many Pizzas through RestaurantPizza
  • A Pizza has many Restaurants through RestaurantPizza
  • A RestaurantPizza belongs to a Restaurant and belongs to a Pizza

Alt text

Table of Contents

Technologies used

python version pytest version flask-sqlalchemy version flask

Installation

1. Clone the repository

git clone https://github.com/JOY19ANYANGO/pizza-restaurants-code-challenge.git

2. Navigate to the project's directory

cd pizza-restaurants-code-challenge

3. Install all the required dependencies

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

4. Enter the pipenv shell

pipenv shell

5.Set up the server

cd server ; python3 app.py
  • Run python3 seed.py to populate database.

Usage

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.

Retrieve records of all restaurants.

To retrieve records of all restaurants navigate to the following URL:http://127.0.0.1:5555/restaurants

Retrieve one restaurant

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

Delete one restaurant.

We can delete a restaurant using postman.

  1. Enter the following URL:http://127.0.0.1:5555/restaurants/:id.Replace id with the actual id of the restaurant
  2. Select the DELETE method and press send.

Alt text

When you press send again you should receive a response ```json { "error": "Restaurant not found" } ``` This shows that the restaurant has been deleted hence it is no longer available.

Retrieve records of all pizzas.

To retrieve records of all restaurants navigate to the following URL:http://127.0.0.1:5555/pizzas

Create a new restaurant_pizza.

We can delete a restaurant using postman.

  1. Enter the following URL:http://127.0.0.1:5555/restaurant_pizzas
  2. Select the POST method.
  3. In the request body enter the following.
{
  "price": 5,
  "pizza_id": 1,
  "restaurant_id": 3
}
  • Press send

Alt text

* You should receive a JSON response of the pizza object and status code 201.This shows that the item was successfully created.

Author & License

Authored by Joy Anyango.

Licensed under the MIT

pizza-restaurants-code-challenge's People

Contributors

joy19anyango avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.