/
appR.py
90 lines (71 loc) · 2.18 KB
/
appR.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
80
81
82
83
84
85
86
87
88
89
90
from flask import Flask, render_template, g, Response, url_for, redirect
from okta import UsersClient
from flask_oidc import OpenIDConnect
from os import environ
from flask import Flask, render_template
from algo import Parse
import sys
import appR
app = Flask(__name__)
app.config["OIDC_CLIENT_SECRETS"] = "client_secrets.json"
app.config["OIDC_COOKIE_SECURE"] = False
app.config["OIDC_CALLBACK_ROUTE"] = "/oidc/callback"
app.config["OIDC_SCOPES"] = ["openid", "email", "profile"]
app.config["SECRET_KEY"] = environ.get("SECRET_KEY")
app.config["OIDC_ID_TOKEN_COOKIE_NAME"] = "oidc_token"
oidc = OpenIDConnect(app)
okta_client = UsersClient("http://dev-363595.okta.com", "006AeB7u4B3zN3IQBYBdXVTluHFvyWucqCqcavGwlt")
@app.before_request
def before_request():
if oidc.user_loggedin:
g.user = okta_client.get_user(oidc.user_getfield("sub"))
else:
g.user = None
@app.route('/')
def iindex():
return render_template("index.html")
@app.route('/filter')
def filter():
return render_template("filter.html")
@app.route("/dashboard")
@oidc.require_login
def dashboard():
return render_template("dashboard.html")
@app.route("/login")
@oidc.require_login
def login():
return redirect(url_for(".hello"))
@app.route("/logout")
def logout():
g.user=None
oidc.logout()
return redirect(url_for(".iindex"))
@app.route('/firstpage/')
def firstpage():
return render_template('firstpage.html')
@app.route('/h/')
def hello():
verose = False
if "-v" in str(sys.argv):
verose = True
p = Parse(verose)
data= p.information
return render_template('home.html', data=data)
@app.route('/allmail/')
def allmail():
verose = False
if "-v" in str(sys.argv):
verose = True
p = Parse(verose)
data= p.information
return render_template('allmail.html', data=data)
@app.route('/allcontact/')
def allcontact():
verose = False
if "-v" in str(sys.argv):
verose = True
p = Parse(verose)
data= p.information
return render_template('allcontact.html', data=data)
if __name__ == '__main__':
app.run(port=7000, debug=True)