-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
44 lines (30 loc) · 1.04 KB
/
app.py
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
39
40
41
42
43
44
import os
import resend
from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap5
app = Flask(__name__)
Bootstrap5(app)
MAIL_ADDRESS = os.environ.get("EMAIL_ADDRES")
@app.route('/')
def main_page():
return render_template("index.html")
resend.api_key = os.environ.get("RESEND_API_KEY")
@app.route('/resume')
def resume():
return render_template("resume.html")
@app.route('/contact', methods=["GET", "POST"])
def contact():
if request.method == "POST":
data = request.form
send_email(data["name"], data["email"], data["phone"], data["message"])
return render_template("contact.html", msg_sent=True)
return render_template("contact.html", msg_sent=False)
def send_email(name, email, phone, message):
response = resend.Emails.send({
"from": "onboarding@resend.dev",
"to": MAIL_ADDRESS,
"subject": 'New Message',
"html": f"Name: {name}\nEmail: {email}\nPhone: {phone}\nMessage:{message}",
})
if __name__ == "__main__":
app.run(debug=False)