mirror of
https://github.com/traberph/mensa-check.git
synced 2026-10-06 18:24:45 +00:00
Compare commits
6
Commits
v1.0.5
...
feature/pwa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
896f13a448 | ||
|
|
076ad18f10 | ||
|
|
da365ac881 | ||
|
|
9064802962 | ||
|
|
4019969841 | ||
|
|
72266fe2e8 |
@@ -1 +1,3 @@
|
||||
.venv
|
||||
venv
|
||||
__pycache__
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
FROM python:3
|
||||
FROM python:3.12-alpine
|
||||
WORKDIR /app
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt --no-cache-dir
|
||||
COPY src/ .
|
||||
CMD [ "fastapi", "run", "api.py" ]
|
||||
@@ -7,11 +7,11 @@ Because of the lack of eggs the spätzle are not sticking together and are just
|
||||
|
||||
Using the allergen information on the mensa website we can check if the spätzle are vegan or not and therefore can decide if one can eat them or not.
|
||||
|
||||
This project serves a simple [website](spaetzle.traberph.de) that checks the spätzle for you.
|
||||
This project serves a simple [website](https://spaetzle.traberph.de) that checks the spätzle for you.
|
||||
|
||||
## How to run
|
||||
Simply run it with docker-compose
|
||||
Simply run it with docker compose
|
||||
|
||||
```
|
||||
docker-compose up
|
||||
docker compose up
|
||||
```
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fastapi[standard]==0.114.0
|
||||
fastapi[standard]==0.115.0
|
||||
Jinja2==3.1.4
|
||||
requests==2.32.3
|
||||
cachetools==5.5.0
|
||||
|
||||
+13
-2
@@ -1,15 +1,18 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
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():
|
||||
@@ -30,11 +33,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"
|
||||
@@ -42,7 +46,7 @@ def checkMensa():
|
||||
else:
|
||||
answer = "No Spätzle today "
|
||||
color = "grey"
|
||||
emoji = "🤷🏻♂️"
|
||||
emoji = "🤷"
|
||||
|
||||
return answer, color, emoji
|
||||
|
||||
@@ -53,3 +57,10 @@ async def root(request: Request):
|
||||
request=request, name="main.html", context={"text": answer, "color": color , "emoji": emoji}
|
||||
)
|
||||
|
||||
@app.get("/manifest.json")
|
||||
async def manifest(request: Request):
|
||||
return FileResponse(path="assets/manifest.json")
|
||||
|
||||
@app.get("/icons/512.png")
|
||||
async def icon(request: Request):
|
||||
return FileResponse(path="assets/logo.png")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Spätzle Check",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
|
||||
<title>{{text}} - {{emoji}}</title>
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user