Refine
This commit is contained in:
8
main.py
8
main.py
@@ -32,8 +32,7 @@ if not os.path.exists(tmpDir):
|
|||||||
os.mkdir(tmpDir)
|
os.mkdir(tmpDir)
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
app.state.is_simulation = False
|
||||||
isSimulation = False
|
|
||||||
|
|
||||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
|
|
||||||
@@ -149,10 +148,9 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
|
|||||||
# 必须用这个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 isSimulation
|
if not app.state.is_simulation:
|
||||||
if not isSimulation:
|
|
||||||
result = run_project(network)
|
result = run_project(network)
|
||||||
isSimulation = False
|
app.state.is_simulation = False
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
raise HTTPException(status_code=400, detail="Is in Simulation")
|
raise HTTPException(status_code=400, detail="Is in Simulation")
|
||||||
|
|||||||
Reference in New Issue
Block a user