Skip to content

Commit

Permalink
api.xudev.io
Browse files Browse the repository at this point in the history
  • Loading branch information
voloder authored Feb 25, 2024
1 parent 11743cf commit 6add398
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
app = FastAPI()

static_files = {
"skolarac/static": "./static",
"skolarac/": "./static/index.html",
"/skolarac/static": "./static",
"/skolarac/": "./static/index.html",
}

sio = socketio.AsyncServer(async_mode="asgi")

sobe: List[Soba] = []

@app.post("skolarac/sobe/udji/")
@app.post("/skolarac/sobe/udji/")
async def udji(kod : str, igrac : Igrac) -> Soba:
for soba in sobe:
if soba.kod == kod:
Expand All @@ -28,7 +28,7 @@ async def udji(kod : str, igrac : Igrac) -> Soba:
return soba
raise HTTPException(status_code=404, detail="Soba ne postoji")

@app.post("skolarac/sobe/kreiraj/")
@app.post("/skolarac/sobe/kreiraj/")
async def kreiraj() -> str:

kod = str(random.randint(1000, 9999))
Expand All @@ -37,14 +37,14 @@ async def kreiraj() -> str:
asyncio.create_task(cisti(soba))
return kod

@app.post("skolarac/sobe/zapocni/")
@app.post("/skolarac/sobe/zapocni/")
async def zapocni(kod : str, postavke : SobaPostavke):
soba = nadji_sobu(kod)
soba.postavke = postavke
asyncio.create_task(zapocni_sobu(soba))
return 200

@app.post("skolarac/sobe/napusti/")
@app.post("/skolarac/sobe/napusti/")
async def napusti(igrac : Igrac):
for soba in sobe:
if igrac in soba.igraci:
Expand All @@ -54,7 +54,7 @@ async def napusti(igrac : Igrac):
return 200
raise HTTPException(status_code=404, detail="Soba ne postoji")

@app.get("skolarac/kategorije/")
@app.get("/skolarac/kategorije/")
async def kategorije():
response = []

Expand Down Expand Up @@ -162,4 +162,4 @@ async def cisti(soba : Soba): # ova funkcija brise sobu ako nije zapoceta 10 min
if(soba.stanje == "cekanje"):
sobe.remove(soba)

app.mount("skolarac/", socketio.ASGIApp(sio, static_files=static_files))
app.mount("/", socketio.ASGIApp(sio, static_files=static_files))

0 comments on commit 6add398

Please sign in to comment.