-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (25 loc) · 942 Bytes
/
main.py
File metadata and controls
38 lines (25 loc) · 942 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
import uvicorn
from pydantic import BaseModel
from fastapi import FastAPI, BackgroundTasks
from Utilities.send_email import send_email
app = FastAPI()
class User(BaseModel):
name:str
email:str
path_to_file = "templates/Photos/Logo-3.png"
@app.post("/Send_email")
async def send_email_one( user:User, background:BackgroundTasks):
EmailGenerator = [user.email]
Name = user.name.upper()
body = {
"title": "Hey",
"name": Name,
"message": "Thank you for choosing Cotazzac"
}
background.add_task(send_email, subject = f"Welcome to Cotzaac - Let's Get Started {Name}",
email_to = EmailGenerator,
data = body,
file = path_to_file)
return {"status": "Welcome Email Message sent successfully to", "name": Name, "email": user.email}
if __name__=="__main__":
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)