cloud_3_3/main.py

30 lines
524 B
Python
Raw Normal View History

2024-11-26 16:53:02 +01:00
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)