Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from worker import get_operator
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
class LookupRequest(BaseModel):
|
| 8 |
+
number: str
|
| 9 |
+
|
| 10 |
+
@app.post("/lookup")
|
| 11 |
+
def lookup(data: LookupRequest):
|
| 12 |
+
try:
|
| 13 |
+
result = get_operator(data.number)
|
| 14 |
+
return {"operator": result}
|
| 15 |
+
except Exception as e:
|
| 16 |
+
raise HTTPException(status_code=500, detail=str(e))
|