-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.py
37 lines (31 loc) · 1.02 KB
/
Server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PriceScraping import BeerProgram
from dbCreator import dBCreator
from flask import Flask
from flask_restful import Api, Resource, reqparse
fileName = "hopsandamltchb.csv"
ps = BeerProgram(fileName, 2, 6, 7, None)
dbC = dBCreator(ps)
dbC.createData()
dbC.printData()
data = dbC.data
app = Flask(__name__)
api = Api(app)
class Ingredient(Resource):
def get(self,name):
for d in data:
if(name == d["Name"]):
#Item found
return d, 200
return "Item not found"
# def post(self, name):
# for d in data:
# if (name == d["Name"]):
# # Adding item to cart (there is no cart in this instance
# if (d[name].inventory_count > 0):
# d[name].inventory_count -= 1
# return "Item added to cart", 200
# else:
# return "No more items in inventory", 400
# return "Item not found"
api.add_resource(Ingredient,"/ingredient/<string:name>")
app.run(debug =True)