-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (37 loc) · 1.45 KB
/
app.py
File metadata and controls
47 lines (37 loc) · 1.45 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
from flask import render_template
from flask import Flask
from flask import request
from flask import redirect
from utils.get_dynamic_data import get_dynamic_data
from utils.get_dynamic_data import build_authorization_url
app = Flask(__name__)
@app.route("/")
def home():
return render_template("default.html")
@app.route("/default")
def default():
return render_template("default.html")
@app.route("/dynamic")
def dynamic(name=None, accounts_count=None):
if name is None or accounts_count is None:
return render_template("default.html")
return render_template("dynamic.html", name=name, accounts_count=accounts_count)
@app.route("/auth")
def auth():
print("In auth endpoint")
# get the authorization URL
authorization_url = build_authorization_url()
# redirect the user to the authorization URL
print("Redirecting to authorization URL:", authorization_url)
return redirect(authorization_url)
@app.route("/auth/callback")
def auth_callback():
print("In auth callback endpoint")
authorization_code = request.args.get('code')
print("Authorization Code received in callback:", authorization_code)
name, accounts_count = get_dynamic_data(authorization_code)
print("Name:", name)
print("Accounts Count:", accounts_count)
if name is None or accounts_count is None:
return render_template("default.html")
return render_template("dynamic.html", name=name, accounts_count=accounts_count)