Files
classquiz-ai/classquiz/kahoot_importer/get.py
T
2025-11-01 15:57:10 +01:00

26 lines
627 B
Python

# SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
#
# SPDX-License-Identifier: MPL-2.0
from aiohttp import ClientSession
from pydantic import BaseModel
from classquiz.kahoot_importer import Card, Kahoot
class _Response(BaseModel):
card: Card
kahoot: Kahoot
async def get(game_id: str) -> _Response | int:
async with (
ClientSession() as session,
session.get(f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true") as response,
):
if response.status == 200:
return _Response(**await response.json())
else:
return response.status