Add method to lock/unlock
This commit is contained in:
17
main.py
17
main.py
@@ -100,17 +100,20 @@ async def fastapi_dump_output(output: str) -> str:
|
|||||||
return dump_output(output)
|
return dump_output(output)
|
||||||
|
|
||||||
@app.get("/isprojectlocked/")
|
@app.get("/isprojectlocked/")
|
||||||
async def fastapi_is_locked(network: str):
|
async def fastapi_is_locked(network: str, req: Request):
|
||||||
return lockedPrjs.get(network) != None
|
client_host = req.client.host
|
||||||
|
return lockedPrjs.get(network) != client_host
|
||||||
|
|
||||||
@app.post("/lockproject/")
|
@app.post("/lockproject/")
|
||||||
async def fastapi_lock_project(network: str, id: str):
|
async def fastapi_lock_project(network: str, req: Request):
|
||||||
lockedPrjs[network] = id
|
client_host = req.client.host
|
||||||
return True
|
lockedPrjs[network] = client_host
|
||||||
|
return client_host
|
||||||
|
|
||||||
@app.post("/unlockproject/")
|
@app.post("/unlockproject/")
|
||||||
async def fastapi_unlock_project(network: str, id: str):
|
async def fastapi_unlock_project(network: str, req: Request):
|
||||||
if lockedPrjs[network] == id:
|
client_host = req.client.host
|
||||||
|
if lockedPrjs[network] == client_host:
|
||||||
del lockedPrjs[network]
|
del lockedPrjs[network]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user