Refine
This commit is contained in:
9
main.py
9
main.py
@@ -154,16 +154,15 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
|
||||
@app.get("/runproject/", response_class = PlainTextResponse)
|
||||
async def fastapi_run_project(network: str) -> str:
|
||||
filename = 'c:/lock.simulation'
|
||||
if os.path.exists(filename):
|
||||
filename2 = 'c:/lock.simulation2'
|
||||
if os.path.exists(filename2):
|
||||
print('file exists')
|
||||
raise HTTPException(status_code=409, detail="is in simulation")
|
||||
else:
|
||||
print('file doesnt exists')
|
||||
f = open(filename, "a")
|
||||
f.write("locksimulaiton")
|
||||
f.close()
|
||||
os.rename(filename, filename2)
|
||||
result = run_project(network)
|
||||
os.remove(filename)
|
||||
os.rename(filename2, filename)
|
||||
return result
|
||||
|
||||
# put in inp folder, name without extension
|
||||
|
||||
Reference in New Issue
Block a user