Script can now run as standalone generator or as flask app
This commit is contained in:
parent
eefbf3c4b4
commit
43788b8f85
60
build.py
60
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'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
|
||||
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'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
|
||||
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__)
|
||||
|
||||
15
menu.yaml
15
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user