Spaces:
Paused
Paused
File size: 395 Bytes
456d207 703e5e6 456d207 703e5e6 456d207 703e5e6 |
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 |
from fastapi import FastAPI
from pydantic import BaseModel
class User_input(BaseModel):
operation:str
x:float
y:float
def calculate(operation, x, y):
return x/y
app = FastAPI()
@app.get("/hello")
def greet_json():
return {"Hello": "World!"}
@app.post("/calculate")
def operate(input:User_input):
res= calculate(input.operation, input.x, input.y)
return res
|