forked from Intro-to-SE-Lab-Fall-20/Group-13
/
app.py
79 lines (51 loc) · 1.82 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#SE Project Email program Willam Giddens, Trey O'neal, Joe Howard, Chad Whitney
import creds
from flask import Flask, render_template, url_for, flash, redirect
from forms import LoginForm, Search
from nylas import APIClient
app = Flask(__name__)
app.config['SECRET_KEY'] = 'ourseecretkeyz1112'
@app.route('/')
def default():
return render_template('default.html')
@app.route('/login',methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
if form.email.data == 'test@test.com' and form.password.data == 'thegoonies':
flash('You have Been Logged In!', 'success')
return redirect(url_for('email'))
else:
flash('Login Failed, Please Check Your Credentials and Try Again', 'danger')
return render_template('default1.html', title='Login', form=form)
@app.route('/success')
def default1():
return render_template('default1.html')
@app.route("/email/", methods=['GET', 'POST'])
def email():
from nylas import APIClient
nylas = APIClient( creds.CLIENT_ID,
creds.CLIENT_SECRET,
creds.ACCESS_TOKEN
)
data = nylas.messages.all()
return render_template("email.html", data=data)
@app.route("/email-search/", methods=['GET', 'POST'])
def emailsearch():
from nylas import APIClient
nylas = APIClient( creds.CLIENT_ID,
creds.CLIENT_SECRET,
creds.ACCESS_TOKEN
)
data = Search()
return render_template("email-search.html", data=data)
@app.route("/emails/<id>", methods=['GET', 'POST'])
def emails(id):
from nylas import APIClient
nylas = APIClient( creds.CLIENT_ID,
creds.CLIENT_SECRET,
creds.ACCESS_TOKEN
)
data = nylas.messages.get(id)
return render_template("emails.html", data=data)
app.run(debug=True, host ='0.0.0.0')