Check isSimulation value when try to run simulation

This commit is contained in:
DingZQ
2023-10-14 16:21:43 +08:00
parent 6c345a29dc
commit 48cdf8f0dd

14
main.py
View File

@@ -1,6 +1,7 @@
import os
import io
import json
import time
from typing import *
from urllib.request import Request
from xml.dom import minicompat
@@ -143,10 +144,21 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
dump_inp(network, inp)
return True
isSimulaion = False
# 必须用这个PlainTextResponse不然每个key都有引号
@app.get("/runproject/", response_class = PlainTextResponse)
async def fastapi_run_project(network: str) -> str:
return run_project(network)
for i in range(10000):
if isSimulaion == False:
break
time.sleep(5)
result = {}
if isSimulaion == False:
result = run_project(network)
isSimulaion = False
return result
# put in inp folder, name without extension
@app.get("/runinp/")