Abhlash commited on
Commit
c59fe8d
·
verified ·
1 Parent(s): 3247c2b

Delete MathEngine.py

Browse files
Files changed (1) hide show
  1. MathEngine.py +0 -34
MathEngine.py DELETED
@@ -1,34 +0,0 @@
1
- from fastapi import FastAPI, HTTPException
2
- from pydantic import BaseModel
3
-
4
- app = FastAPI()
5
-
6
- class CalculationRequest(BaseModel):
7
- a: float
8
- b: float
9
- operation: str
10
-
11
- @app.post("/calculate")
12
- def calculate(request: CalculationRequest):
13
- a = request.a
14
- b = request.b
15
- operation = request.operation.lower()
16
-
17
- if operation == "add":
18
- result = a + b
19
- elif operation == "subtract":
20
- result = a - b
21
- elif operation == "multiply":
22
- result = a * b
23
- elif operation == "divide":
24
- if b == 0:
25
- raise HTTPException(status_code=400, detail="Division by zero is not allowed")
26
- result = a / b
27
- else:
28
- raise HTTPException(status_code=400, detail="Invalid operation")
29
-
30
- return {"result": result}
31
-
32
- @app.get("/")
33
- def read_root():
34
- return {"message": "Hello, World!"}