Refine
This commit is contained in:
5
main.py
5
main.py
@@ -34,8 +34,6 @@ if not os.path.exists(tmpDir):
|
|||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
lock = asyncio.Lock()
|
|
||||||
|
|
||||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
@@ -147,10 +145,11 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
|
|||||||
dump_inp(network, inp)
|
dump_inp(network, inp)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
lock = asyncio.Lock()
|
||||||
|
|
||||||
# 必须用这个PlainTextResponse,不然每个key都有引号
|
# 必须用这个PlainTextResponse,不然每个key都有引号
|
||||||
@app.get("/runproject/", response_class = PlainTextResponse)
|
@app.get("/runproject/", response_class = PlainTextResponse)
|
||||||
async def fastapi_run_project(network: str) -> str:
|
async def fastapi_run_project(network: str) -> str:
|
||||||
global lock
|
|
||||||
if lock.locked():
|
if lock.locked():
|
||||||
raise HTTPException(status_code=400, detail="is in simulation")
|
raise HTTPException(status_code=400, detail="is in simulation")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user