From 86137ca92c34263243fdf5011a80000f60e924bf Mon Sep 17 00:00:00 2001 From: KreativeThinker Date: Wed, 15 Nov 2023 15:26:44 +0530 Subject: [PATCH 1/2] Added api.py --- src/pwncore/routes/api.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/pwncore/routes/api.py diff --git a/src/pwncore/routes/api.py b/src/pwncore/routes/api.py new file mode 100644 index 0000000..6a06b96 --- /dev/null +++ b/src/pwncore/routes/api.py @@ -0,0 +1,22 @@ +from fastapi import APIRouter + +router = APIRouter(prefix="/api/ctf", tags=["flag"]) + + +@router.get("/view/{ctf_id}") +async def view(ctf_id: int): + # fetch ctf + return {"ctf_name": "Key Verifier", "author": "mradigen", "container": "127.0.0.1:8000"} + + +@router.get("/flag/{ctf_id}") +async def flag(ctf_id: int): + # compare flag against database + return {"status": True} + + +@router.get("/hint/{ctf_id}") +async def hint(ctf_id: int): + # fetch hint + # reduce points + return {"hint": "Ask the cat, it was there when it was hidden", "points": 144} From 88f7ec49117008f7958ea8ddfd3ca0dca10dfc2d Mon Sep 17 00:00:00 2001 From: KreativeThinker Date: Wed, 15 Nov 2023 15:34:55 +0530 Subject: [PATCH 2/2] Moved api.py to /ctf/__init__.py --- src/pwncore/routes/api.py | 22 ---------------------- src/pwncore/routes/ctf/__init__.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 src/pwncore/routes/api.py diff --git a/src/pwncore/routes/api.py b/src/pwncore/routes/api.py deleted file mode 100644 index 6a06b96..0000000 --- a/src/pwncore/routes/api.py +++ /dev/null @@ -1,22 +0,0 @@ -from fastapi import APIRouter - -router = APIRouter(prefix="/api/ctf", tags=["flag"]) - - -@router.get("/view/{ctf_id}") -async def view(ctf_id: int): - # fetch ctf - return {"ctf_name": "Key Verifier", "author": "mradigen", "container": "127.0.0.1:8000"} - - -@router.get("/flag/{ctf_id}") -async def flag(ctf_id: int): - # compare flag against database - return {"status": True} - - -@router.get("/hint/{ctf_id}") -async def hint(ctf_id: int): - # fetch hint - # reduce points - return {"hint": "Ask the cat, it was there when it was hidden", "points": 144} diff --git a/src/pwncore/routes/ctf/__init__.py b/src/pwncore/routes/ctf/__init__.py index 03c1749..9cafd29 100644 --- a/src/pwncore/routes/ctf/__init__.py +++ b/src/pwncore/routes/ctf/__init__.py @@ -27,3 +27,16 @@ async def ctf_list(): async def ctf_get(ctf_id: int): # Get ctf from ctf_id return {"status": "logged in!"} + + +@router.get("/flag/{ctf_id}") +async def flag(ctf_id: int): + # compare flag against database + return {"status": True} + + +@router.get("/hint/{ctf_id}") +async def hint(ctf_id: int): + # fetch hint + # reduce points + return {"hint": "Ask the cat, it was there when it was hidden", "points": 144}