Check isSimulation value when try to run simulation
This commit is contained in:
14
main.py
14
main.py
@@ -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/")
|
||||
|
||||
Reference in New Issue
Block a user