-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (33 loc) · 1.17 KB
/
main.py
File metadata and controls
43 lines (33 loc) · 1.17 KB
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
from flask import Flask, render_template , request , send_from_directory
import smtplib
import os
from dotenv import load_dotenv
load_dotenv()
MY_EMAIL = os.getenv("MY_EMAIL")
MY_PASSWORD = os.getenv("MY_PASSWORD")
app = Flask(__name__)
@app.route("/")
def hello_world():
return render_template("index.html")
@app.route('/contact', methods = ['POST'])
def contact():
email = request.form.get('email')
message = request.form.get('message')
try:
with smtplib.SMTP("smtp.gmail.com", 587) as connection:
connection.starttls() # Secure the connection
connection.login(MY_EMAIL, MY_PASSWORD)
connection.sendmail(
from_addr=MY_EMAIL,
to_addrs="rachitmakwana15@gmail.com",
msg=f"Subject:Customer Inquiry\n\nCustomer email: {email}\nMessage: {message}"
)
return "Form submitted successfully!"
except Exception as e:
print(f'Error Sending email : {e}')
return "Failed to send mail"
@app.route('/resume')
def resume():
return send_from_directory(directory='static/files', path='resume.pdf')
if __name__ == "__main__":
app.run(debug=True)