30 lines
524 B
Python
30 lines
524 B
Python
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
import subprocess
|
|
import uvicorn
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class ComputeInput(BaseModel):
|
|
a: str
|
|
b: str
|
|
sigma: str
|
|
|
|
|
|
@app.post("/compute")
|
|
async def compute(data: ComputeInput):
|
|
a = data.a
|
|
b = data.b
|
|
sigma = data.sigma
|
|
|
|
result = subprocess.run(
|
|
['./computeC', a, b, sigma],
|
|
capture_output=True,
|
|
text=True
|
|
)
|
|
return result.stdout.strip()
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=5000)
|