Script can now run as standalone generator or as flask app

This commit is contained in:
Justus Grunow 2025-01-27 07:03:46 -05:00
parent eefbf3c4b4
commit 43788b8f85
2 changed files with 57 additions and 18 deletions

View File

@ -7,27 +7,51 @@ env = Environment(
autoescape=select_autoescape() autoescape=select_autoescape()
) )
def generateMenu():
with open('menu.yaml', 'r') as file: with open('menu.yaml', 'r') as file:
menu = yaml.safe_load(file) menu = yaml.safe_load(file)
templateMenu = env.get_template("menu.html") templateMenu = env.get_template("menu.html")
templateRecipes = env.get_template("recipes.html") templateRecipes = env.get_template("recipes.html")
print(menu)
for bev, details in menu['menu'].items(): for bev, details in menu['menu'].items():
#print(bev) #print(bev)
print(bev) print(bev)
#for ingredient in details['ingredients']: #for ingredient in details['ingredients']:
# print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>') # print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
print(markdown.markdown(details['directions']))
details['directions_html'] = 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}
if (__name__ == 'build'):
from flask import Flask
app = Flask(__name__)
@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: with open('index.html', 'w') as file:
file.write(templateMenu.render(bevs = menu['menu'])) file.write(html['menuHtml'])
with open('recipes.html', 'w') as file: with open('recipes.html', 'w') as file:
file.write(templateRecipes.render(bevs = menu['menu'])) file.write(html['recipesHtml'])
for ingredient in menu['out_of_stock']:
print(ingredient) print(generateMenu())
#print(menu)
#
#
#
#for ingredient in menu['out_of_stock']:
# print(ingredient)
#
#print(__name__)

View File

@ -102,6 +102,21 @@ menu:
directions: | directions: |
1. Blend orange juice and Campari until frothy. 1. Blend orange juice and Campari until frothy.
1. Strain into ice-filled highball. 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: out_of_stock:
- Rye whiskey - Rye whiskey