Skip to content

Commit 37982d1

Browse files
authored
Create app.py
1 parent 5a2900c commit 37982d1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

38-Email-sender-script/app.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from fastapi import FastAPI
2+
from pydantic import BaseModel, EmailStr
3+
from email_sender import send_bulk_emails
4+
import threading
5+
6+
app = FastAPI(title="Bulk Email Sender API")
7+
8+
class BulkEmailRequest(BaseModel):
9+
csv_file: str
10+
11+
@app.post("/send_bulk")
12+
def send_bulk(request: BulkEmailRequest):
13+
# Run in background to avoid blocking
14+
threading.Thread(target=send_bulk_emails, args=(request.csv_file,)).start()
15+
return {"status": "Emails are being sent in background"}

0 commit comments

Comments
 (0)