forked from satkarjuneja/Analytical-Physics-Models
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.py
More file actions
29 lines (21 loc) · 697 Bytes
/
backend.py
File metadata and controls
29 lines (21 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import uvicorn
from fastapi import FastAPI
# from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
import subprocess
app = FastAPI()
# @app.get("/", response_class=HTMLResponse)
# def root():
# with open("index.html", "r") as root_file:
# return root_file.read()
@app.post("/api/simulate")
def read_root(payload: dict):
FILE = payload.get("path")
subprocess.run(["python", FILE])
"""
Endpoint that returns a simple welcome message.
"""
return {"message": "Hello, World!"}
app.mount("/", StaticFiles(directory=".",html=True), name="static")
if __name__ == "__main__":
uvicorn.run(app,host="0.0.0.0",port=7860)