-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.py
67 lines (49 loc) · 1.71 KB
/
routes.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from flask import Flask, render_template, request
from forms import ContactUsForm
from flask_mail import Message, Mail
from secrets import SECRET_KEY, MAIL_USERNAME, MAIL_PASSWORD, RECIPIENTS
mail = Mail()
app = Flask(__name__)
app.secret_key = SECRET_KEY
app.config["MAIL_SERVER"] = 'smtp.gmail.com'
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = MAIL_USERNAME
app.config["MAIL_PASSWORD"] = MAIL_PASSWORD
mail.init_app(app)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/requirements')
def requirements():
return render_template('requirements.html')
@app.route('/connectivity')
def connectivity():
return render_template('connectivity.html')
@app.route('/contact-us', methods=['GET', 'POST'])
def contact_us():
form = ContactUsForm()
if request.method == 'POST':
if form.validate() == True:
msg = Message('New Message SELF-16',
sender=('SELF-16 DoNotReply', MAIL_USERNAME),
recipients = RECIPIENTS)
msg.body = """Name:
%s %s
Email:
%s <mailto:%s>
Message:
%s
________________________________
This message was submitted from your website contact form""" % (form.first_name.data, form.last_name.data, form.email.data, form.email.data, form.message.data)
mail.send(msg)
return render_template('contact-us.html', success=True)
else:
render_template('contact-us.html', form=form)
elif request.method == 'GET':
return render_template('contact-us.html', form=form)
@app.route('/sea-trials')
def sea_trials():
return render_template('sea-trials.html')
if __name__ == '__main__':
app.run()