Writing generator in python. MVP working

This commit is contained in:
Justus Grunow 2025-01-23 21:47:49 -05:00
parent 2500cfb546
commit be587e755f

39
build.py Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python
import yaml
def writeLine(string):
global menuOut
menuOut += f"{string}\r\n"
with open('menu.yaml', 'r') as file:
menu = yaml.safe_load(file)
#print(menu['menu'])
menuOut = '''\
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Cocktail Menu</title>
</head>
<body>
'''
for bev in menu['menu']:
#print(bev)
for name in bev:
print(name)
writeLine(f'<h2>{name}</h2>')
writeLine('<ul>')
for ingredient in bev[name]['ingredients']:
writeLine(f'<li>{ingredient}</li>')
writeLine('</ul>')
menuOut += '''\
</body>
</html>
'''
with open('index.html', 'w') as file:
file.write(menuOut)