From 0c05e7a809ced557761ee50250e1ee8ea0623574 Mon Sep 17 00:00:00 2001 From: Vitaliy Turov Date: Thu, 6 Feb 2025 19:00:53 +0300 Subject: [PATCH] Save state --- python/main.py | 89 +++++--------------------------------------------- 1 file changed, 8 insertions(+), 81 deletions(-) diff --git a/python/main.py b/python/main.py index fab4995..51a2885 100644 --- a/python/main.py +++ b/python/main.py @@ -1,84 +1,11 @@ -import random +from fastapi import FastAPI -word_dict = { - "питон": "интерпритируемый язык программирования", - "голанг": "компилируемый язык программирования", -} +app = FastAPI() +@app.get("/") +async def root(): + return {"message" : "Hello World"} -def game(): - word_number = random.randint(0, len(word_dict) - 1) - word = list(word_dict.keys())[word_number] - describe = word_dict[word] - guess = ['_' for _ in word] - value_guess = len(word) - - print(describe) - print(" ".join(guess)) - while value_guess > 0: - character = input("Введите букву: ") - if word.count(character) >= 1: - for index, value in enumerate(word): - if character == value: - guess[index] = value - else: - value_guess -= 1 - print(f"У вас осталось {value_guess} попыток") - if guess.count('_') == 0: - print(" ".join(guess)) - break - - print(" ".join(guess)) - else: - print(f"GAME OVER =(") - - - - -def run_game(): - game() - - -def save_game(): - pass - - -def load_game(): - pass - - -def exit_game(): - exit(0) - - -def menu(): - print( - """ - 1. Начать игру - 2. Сохранить - 3. Загрузить - 4. Выход - """ - ) - - -def read_selector(): - key = int(input(":")) - match key: - case 1: - run_game() - case 2: - save_game() - case 3: - load_game() - case 4: - exit_game() - - -def main(): - menu() - read_selector() - - -if __name__ == "__main__": - main() +@app.delete("/user") +async def root(): + return {"message" : "User delete"} \ No newline at end of file