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__":
|
2024-11-26 17:23:13 +01:00
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|