Quelle-Badges (OT/WF), Legende verschoben, Footer mit Emojis, A11y-Verbesserungen; Generator: Merge OpenThesaurus+wordfreq; Dockerfile/Gunicorn hinzugefügt

This commit is contained in:
2025-08-19 11:26:02 +02:00
parent d6d23a230e
commit 916f6510d8
5 changed files with 26823 additions and 60 deletions

46
app.py
View File

@@ -1,24 +1,37 @@
from pathlib import Path
import json
from typing import Tuple, Dict, List
from flask import Flask, render_template, request
app = Flask(__name__)
def load_words() -> list[str]:
data_path = Path(__file__).parent / "data" / "words_de_5.txt"
if not data_path.exists():
return []
words: list[str] = []
with data_path.open("r", encoding="utf-8") as f:
for line in f:
word = line.strip().lower()
if len(word) == 5 and word.isalpha():
words.append(word)
return words
def load_words() -> Tuple[List[str], Dict[str, List[str]]]:
data_dir = Path(__file__).parent / "data"
txt_path = data_dir / "words_de_5.txt"
json_path = data_dir / "words_de_5_sources.json"
words: List[str] = []
sources_map: Dict[str, List[str]] = {}
if txt_path.exists():
with txt_path.open("r", encoding="utf-8") as f:
for line in f:
word = line.strip().lower()
if len(word) == 5 and word.isalpha():
words.append(word)
if json_path.exists():
try:
sources_map = json.loads(json_path.read_text(encoding="utf-8"))
except Exception:
sources_map = {}
return words, sources_map
def filter_words(words: list[str], position_letters: list[str], includes_text: str, excludes_text: str) -> list[str]:
results: list[str] = []
def filter_words(words: List[str], position_letters: List[str], includes_text: str, excludes_text: str) -> List[str]:
results: List[str] = []
includes_letters = [ch for ch in includes_text.lower() if ch.isalpha()]
excludes_letters = [ch for ch in excludes_text.lower() if ch.isalpha()]
for word in words:
@@ -37,9 +50,9 @@ def filter_words(words: list[str], position_letters: list[str], includes_text: s
@app.route("/", methods=["GET", "POST"])
def index():
all_words = load_words()
results: list[str] | None = None
pos: list[str] = ["", "", "", "", ""]
all_words, sources_map = load_words()
results: List[str] | None = None
pos: List[str] = ["", "", "", "", ""]
includes: str = ""
excludes: str = ""
if request.method == "POST":
@@ -60,6 +73,7 @@ def index():
includes=includes,
excludes=excludes,
words_count=len(all_words),
sources_map=sources_map,
)