Skip to content

Commit

Permalink
check the right ingredients
Browse files Browse the repository at this point in the history
  • Loading branch information
traberph committed Oct 8, 2024
1 parent 4f4ec34 commit 72266fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from cachetools import cached, TTLCache
from bs4 import BeautifulSoup
import requests
import re


cache = TTLCache(maxsize=1, ttl=3600)
app = FastAPI()
templates = Jinja2Templates(directory="template")
regex = re.compile(r'Spätzle <sup>([^/]*)<\/sup>')

@cached(cache)
def checkMensa():
Expand All @@ -30,11 +32,12 @@ def checkMensa():
break

if spaetzle is not None:
ingredients = spaetzle.find('sup').text
ingredients = re.search(regex, str(spaetzle)).group(1)
if '28' in ingredients:
answer = "Spätzle with egg today"
color = "green"
emoji = "✅"

else:
answer = "WARNING: Spätzle without egg today"
color = "red"
Expand Down

0 comments on commit 72266fe

Please sign in to comment.