added word shuffle functionality

This commit is contained in:
tom.hempel
2025-09-18 10:26:33 +02:00
parent 6a6b2b9936
commit e6d73a2bcb
3 changed files with 48 additions and 12 deletions

View File

@ -79,6 +79,9 @@ class Word(BaseModel):
timeSeconds: float
word: str
class WordList(BaseModel):
words: list[str]
@app.post("/word")
def read_word(word: Word):
msg = f"CHARADE:{word.lastWordStatus};{word.timeSeconds};{word.word}"
@ -86,6 +89,13 @@ def read_word(word: Word):
sock.sendto(msg.encode('utf-8'), (word.target, 5000))
return { "status": "ok" }
@app.post("/shuffle")
def shuffle_words(word_list: WordList):
import random
shuffled = word_list.words.copy()
random.shuffle(shuffled)
return { "status": "ok", "shuffled_words": shuffled }
# SSE endpoint
@app.get("/news")