-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
60 lines (54 loc) · 1.86 KB
/
app.py
File metadata and controls
60 lines (54 loc) · 1.86 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from flask import Flask, render_template, request, redirect, url_for
'''
makes a variable called 'app' that is the
source of this web app so i can tie differnt web functions or routesto it
'''
app = Flask(__name__)
'''
app.config.update(dict(
SECRET_KEY="powerful secretkey",
WTF_CSRF_SECRET_KEY="a csrf secret key",
MAIL_SERVER = "localhost",
MAIL_PORT = 25,
MAIL_USE_SSL = True,
MAIL_USERNAME = 'srikumar.sanjay@gmail.com',
MAIL_PASSWORD = 'blaster1',
))
def send_email(to_email,from_email,mydict):
result_dict = {}
try:
msg = Message("Message from your website",sender=from_email,recipients=[to_email])
msg.body="Email from your website"
msg.html= render_template("email.html",contact_email=mydict['contact_email'],message=mydict['message'])
mail.send(msg)
flash("Thanks for contacting me. I will get back to you soon!","success")
except Exception as e:
flash("Error sending email".format(str(e)),"error")
________________________________________________________________________________
NOTES:
routes '/' (which is essentially the landing page)
________________________________________________________________________________
Can pass additional arguments to render_template
EX:
temp= "hi"
render_template("index.html", temp)
IN HTML, I use {{temp}}
'''
@app.route("/")
def index():
return render_template("index.html")
@app.route("/Resume")
def resume():
return redirect("https://www.terpconnect.umd.edu/~sanjays/Personal-Website%20Externals/Sanjay_Srikumar_Resume.pdf")
@app.route("/<string:name>")
def general(name):
return ("<h1>This Page Does Not Exist</h1>")
@app.route("/about")
def about():
return render_template("about_me.html")
@app.route("/Projects")
def projects():
return render_template("Projects.html")
@app.route("/Contact")
def contact():
return render_template("contact.html")