Giter Club home page Giter Club logo

order-pizza-api's Introduction

logo

Order Pizza API

A RESTful API for a pizza restaurant ordering system

Run in Postman

Built with (but not limited to) :

Setup

  1. git clone https://github.com/mhshahzad/order-pizza-api
  2. cd order-pizza-api
  3. pip install -r requirements.txt or place virtual environment and then install
  4. python3 server.py (tested on python 3.8.0)

Usage

Example Response

curl -s http://localhost:8000/api/orders
[
  {
    "Crust": "NORMAL",
    "Flavor": "BEEF-NORMAL",
    "Order_ID": 1,
    "Size": "M",
    "Table_No": 1,
    "Timestamp": "2018-12-12T13:42:13.704148+00:00"
  },
  {
    "Crust": "THIN",
    "Flavor": "CHEESE",
    "Order_ID": 2,
    "Size": "S",
    "Table_No": 5,
    "Timestamp": "2018-12-12T13:42:13.704148+00:00"
  },
  {
    "Crust": "NORMAL",
    "Flavor": "CHICKEN-FAJITA",
    "Order_ID": 3,
    "Size": "L",
    "Table_No": 3,
    "Timestamp": "2018-12-12T13:42:13.720690+00:00"
  }
]

Endpoints

  • POST : /auth
  curl -X POST -H "Content-Type: application/json" -d '{"username": "test", "password": "test"}'  http://localhost:8000/api/auth
  • POST : /orders (Access Token is required)
curl 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer <JWT>" 
  -X POST 
  -d  
 '{
    "Flavor": "ABC", 
    "Crust": "XYZ",
    "Size": "XL", 
    "Table_No": 9
  }' 
  http://localhost:8000/api/orders

Do replace the <JWT> in the above request with the token you have acquired.

  • DELETE : /orders/{Order_ID}
curl -X DELETE http://localhost:8000/api/orders/1

License

MIT

order-pizza-api's People

Contributors

imgbotapp avatar mhshahzad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

order-pizza-api's Issues

Interal error happens when trying to delete an order that doesn't exist.

Title explains the whole problem itself.

Error message:

{
  "detail": "The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.",
  "status": 500,
  "title": "Internal Server Error",
  "type": "about:blank"
}

Not enough segment when adding order

curl -X POST --header 'Content-Type: application/json' --header 'authorization: Bearer <JWT>' --header 'Accept: application/json' -d '{"Crust":"a", "Flavor":"b", "Size":"Big", "Table_No":3}' 'https://order-pizza-api.herokuapp.com/api/orders'

I tried the above command to add order to your web app, it keeps returning

{"msg":"Not enough segments"}

I have no clue what this error is about.

Authorization token

(1) The website didn't tell us how to use authorization token. (Spoiler: add the following request header "authorization: Bearer <JWT>")

(2) When I am poking at authorization header, it returned the following error message

{"msg":"Bad Authorization header. Expected value 'Bearer <JWT>'"}

It just spits out the token needed to add an order, this is definitely a bug right?

(3) How am I suppose to do with the token generated by "/auth"? Looks like the token is useless.

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.