mirror of
https://github.com/traberph/mensa-check.git
synced 2026-10-06 18:24:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9064802962 | ||
|
|
4019969841 | ||
|
|
72266fe2e8 |
+2
-1
@@ -1 +1,2 @@
|
|||||||
.venv
|
.venv
|
||||||
|
__pycache__
|
||||||
+3
-4
@@ -1,7 +1,6 @@
|
|||||||
FROM python:3
|
FROM python:3.12-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install -r requirements.txt --no-cache-dir
|
||||||
|
|
||||||
COPY src/ .
|
COPY src/ .
|
||||||
CMD [ "fastapi", "run", "api.py" ]
|
CMD [ "fastapi", "run", "api.py" ]
|
||||||
@@ -10,8 +10,8 @@ Using the allergen information on the mensa website we can check if the spätzle
|
|||||||
This project serves a simple [website](spaetzle.traberph.de) that checks the spätzle for you.
|
This project serves a simple [website](spaetzle.traberph.de) that checks the spätzle for you.
|
||||||
|
|
||||||
## How to run
|
## How to run
|
||||||
Simply run it with docker-compose
|
Simply run it with docker compose
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up
|
docker compose up
|
||||||
```
|
```
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
fastapi[standard]==0.114.0
|
fastapi[standard]==0.115.0
|
||||||
Jinja2==3.1.4
|
Jinja2==3.1.4
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
cachetools==5.5.0
|
cachetools==5.5.0
|
||||||
beautifulsoup4==4.12.3
|
beautifulsoup4==4.12.3
|
||||||
+4
-1
@@ -5,11 +5,13 @@ from fastapi.templating import Jinja2Templates
|
|||||||
from cachetools import cached, TTLCache
|
from cachetools import cached, TTLCache
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import requests
|
import requests
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
cache = TTLCache(maxsize=1, ttl=3600)
|
cache = TTLCache(maxsize=1, ttl=3600)
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
templates = Jinja2Templates(directory="template")
|
templates = Jinja2Templates(directory="template")
|
||||||
|
regex = re.compile(r'Spätzle <sup>([^/]*)<\/sup>')
|
||||||
|
|
||||||
@cached(cache)
|
@cached(cache)
|
||||||
def checkMensa():
|
def checkMensa():
|
||||||
@@ -30,11 +32,12 @@ def checkMensa():
|
|||||||
break
|
break
|
||||||
|
|
||||||
if spaetzle is not None:
|
if spaetzle is not None:
|
||||||
ingredients = spaetzle.find('sup').text
|
ingredients = re.search(regex, str(spaetzle)).group(1)
|
||||||
if '28' in ingredients:
|
if '28' in ingredients:
|
||||||
answer = "Spätzle with egg today"
|
answer = "Spätzle with egg today"
|
||||||
color = "green"
|
color = "green"
|
||||||
emoji = "✅"
|
emoji = "✅"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
answer = "WARNING: Spätzle without egg today"
|
answer = "WARNING: Spätzle without egg today"
|
||||||
color = "red"
|
color = "red"
|
||||||
|
|||||||
Reference in New Issue
Block a user