diff --git a/build.py b/build.py index 1a2525b..fb74fd0 100755 --- a/build.py +++ b/build.py @@ -7,27 +7,51 @@ env = Environment( autoescape=select_autoescape() ) -with open('menu.yaml', 'r') as file: - menu = yaml.safe_load(file) +def generateMenu(): + with open('menu.yaml', 'r') as file: + menu = yaml.safe_load(file) -templateMenu = env.get_template("menu.html") -templateRecipes = env.get_template("recipes.html") + templateMenu = env.get_template("menu.html") + templateRecipes = env.get_template("recipes.html") -print(menu) + for bev, details in menu['menu'].items(): + #print(bev) + print(bev) + #for ingredient in details['ingredients']: + # print(f'
  • {ingredient[list(ingredient)[0]]} {list(ingredient)[0]}
  • ') + details['directions_html'] = markdown.markdown(details['directions']) -for bev, details in menu['menu'].items(): - #print(bev) - print(bev) - #for ingredient in details['ingredients']: - # print(f'
  • {ingredient[list(ingredient)[0]]} {list(ingredient)[0]}
  • ') - print(markdown.markdown(details['directions'])) - details['directions_html'] = markdown.markdown(details['directions']) + menuHtml = templateMenu.render(bevs = menu['menu']) + recipesHtml = templateRecipes.render(bevs = menu['menu']) + return {'menuHtml': menuHtml, 'recipesHtml': recipesHtml} -with open('index.html', 'w') as file: - file.write(templateMenu.render(bevs = menu['menu'])) +if (__name__ == 'build'): + from flask import Flask -with open('recipes.html', 'w') as file: - file.write(templateRecipes.render(bevs = menu['menu'])) + app = Flask(__name__) -for ingredient in menu['out_of_stock']: - print(ingredient) + @app.route("/") + def serveMenu(): + return generateMenu()['menuHtml'] + @app.route("/recipes") + def serveRecipes(): + return generateMenu()['recipesHtml'] + +elif (__name__ == '__main__'): + html = generateMenu() + with open('index.html', 'w') as file: + file.write(html['menuHtml']) + + with open('recipes.html', 'w') as file: + file.write(html['recipesHtml']) + + +print(generateMenu()) +#print(menu) +# +# +# +#for ingredient in menu['out_of_stock']: +# print(ingredient) +# +#print(__name__) diff --git a/menu.yaml b/menu.yaml index 60c1155..923f8c4 100644 --- a/menu.yaml +++ b/menu.yaml @@ -102,6 +102,21 @@ menu: directions: | 1. Blend orange juice and Campari until frothy. 1. Strain into ice-filled highball. + White Russian: + base: Vodka + category: + ingredients: + Vodka: 1.5 oz + Kahlua: 1 oz + Heavy cream: 1 oz + Instant coffee: 0.5 tsp + directions: | + 1. Chill vodka + 1. Add large cube to lowball glass + 1. Sprinkle instant coffee powder over ice + 1. Slowly pour vodka around ice + 1. Slowly pour Kahlua around ice + 1. Slowly pour cream over ice out_of_stock: - Rye whiskey