diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -11,6 +11,9 @@ app = Flask(__name__) with open("./data/beers.json") as beers_json: beer = json.loads(beers_json.read()) +with open('./data/brewery_names.json', 'w') as f: + brewery_names = json.load(f) + @app.route('/') def index(): @@ -30,8 +33,8 @@ def get_brewery_list(brewery_id): @app.route('/brewery/<brewery_id>/<beer_id>') def get_beer_details(brewery_id, beer_id): - beer_result = beer_lookup(brewery_id, beer_id) - beerinfo = BeerInfo(beer_result) + beer_result, brewery_name = beer_lookup(brewery_id, beer_id) + beerinfo = BeerInfo(beer_result, brewery_name) attrs = ['Burnt', 'Bready', 'Malty', 'Dark', 'Floral', 'Hoppy', 'Dank', 'Grassy', 'Boozy', 'Warming', 'Bitter', 'Wheaty', 'Sour', 'Barnyardy', 'Woody', 'Smoky', 'Roasty', 'Yeasty', 'Sweet', @@ -44,7 +47,7 @@ def beer_lookup(brewery_id, beer_id): item_id = brewery_id + "-" + beer_id try: beer_result = beer[item_id] - return beer_result + return beer_result, brewery_names[brewery_id] except: return None @@ -57,11 +60,12 @@ def find_beers_from_brewery(brewery_id): class BeerInfo(object): - def __init__(self, item_json): + def __init__(self, item_json, brewery_name): self.parent_style = item_json[1][1] self.base_style = item_json[1][0] self.name = item_json[0] self.abv = item_json[2] + self.brewer = brewery_name class Brewery(object): |