Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -132,8 +132,14 @@ async def status():
|
|
| 132 |
# === In-memory OTP store ===
|
| 133 |
OTP_STORE = {}
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
@fastapi_app.post("/send-otp")
|
| 136 |
-
async def send_otp(
|
|
|
|
| 137 |
otp = str(random.randint(100000, 999999))
|
| 138 |
expiry = datetime.now() + timedelta(minutes=10)
|
| 139 |
OTP_STORE[email] = (otp, expiry)
|
|
@@ -150,7 +156,8 @@ async def send_otp(email: str = Form(...)):
|
|
| 150 |
smtp.send_message(msg)
|
| 151 |
return {"status": "sent"}
|
| 152 |
except Exception as e:
|
| 153 |
-
return JSONResponse({"error": str(e)}, status_code=500)
|
|
|
|
| 154 |
|
| 155 |
@fastapi_app.post("/verify-otp")
|
| 156 |
async def verify_otp(email: str = Form(...), otp: str = Form(...)):
|
|
|
|
| 132 |
# === In-memory OTP store ===
|
| 133 |
OTP_STORE = {}
|
| 134 |
|
| 135 |
+
from pydantic import BaseModel
|
| 136 |
+
|
| 137 |
+
class EmailRequest(BaseModel):
|
| 138 |
+
email: str
|
| 139 |
+
|
| 140 |
@fastapi_app.post("/send-otp")
|
| 141 |
+
async def send_otp(request: EmailRequest):
|
| 142 |
+
email = request.email
|
| 143 |
otp = str(random.randint(100000, 999999))
|
| 144 |
expiry = datetime.now() + timedelta(minutes=10)
|
| 145 |
OTP_STORE[email] = (otp, expiry)
|
|
|
|
| 156 |
smtp.send_message(msg)
|
| 157 |
return {"status": "sent"}
|
| 158 |
except Exception as e:
|
| 159 |
+
return JSONResponse({"status": "error", "error": str(e)}, status_code=500)
|
| 160 |
+
|
| 161 |
|
| 162 |
@fastapi_app.post("/verify-otp")
|
| 163 |
async def verify_otp(email: str = Form(...), otp: str = Form(...)):
|