Script can now run as standalone generator or as flask app
This commit is contained in:
parent
eefbf3c4b4
commit
43788b8f85
50
build.py
50
build.py
@ -7,27 +7,51 @@ env = Environment(
|
|||||||
autoescape=select_autoescape()
|
autoescape=select_autoescape()
|
||||||
)
|
)
|
||||||
|
|
||||||
with open('menu.yaml', 'r') as file:
|
def generateMenu():
|
||||||
|
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'])
|
||||||
|
|
||||||
with open('index.html', 'w') as file:
|
menuHtml = templateMenu.render(bevs = menu['menu'])
|
||||||
file.write(templateMenu.render(bevs = menu['menu']))
|
recipesHtml = templateRecipes.render(bevs = menu['menu'])
|
||||||
|
return {'menuHtml': menuHtml, 'recipesHtml': recipesHtml}
|
||||||
|
|
||||||
with open('recipes.html', 'w') as file:
|
if (__name__ == 'build'):
|
||||||
file.write(templateRecipes.render(bevs = menu['menu']))
|
from flask import Flask
|
||||||
|
|
||||||
for ingredient in menu['out_of_stock']:
|
app = Flask(__name__)
|
||||||
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__)
|
||||||
|
|||||||
15
menu.yaml
15
menu.yaml
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user