Skip to content

Commit fd05726

Browse files
committed
Move index() inline html into its template
1 parent 716956d commit fd05726

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
def index():
1616
if not session.get("user"):
1717
return redirect(url_for("login"))
18-
return """Welcome, %s.
19-
<li><a href='/graphcall'>Call Microsoft Graph API</a></li>
20-
<li><a href="/logout">Logout</a></li>
21-
""" % session["user"].get("name")
18+
return render_template('index.html', user=session["user"])
2219

2320
@app.route("/login")
2421
def login():
@@ -48,7 +45,7 @@ def authorized():
4845

4946
@app.route("/logout")
5047
def logout():
51-
session["user"] = None # Mark current session as not-logged-in
48+
session["user"] = None # Log out from this app from its session
5249
# session.clear() # If you prefer, this would nuke the user's token cache too
5350
return redirect( # Also need to logout from Microsoft Identity platform
5451
"https://login.microsoftonline.com/common/oauth2/v2.0/logout"

templates/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
</head>
6+
<body>
7+
<h1>Microsoft Identity Python Web App</h1>
8+
Welcome {{ user.get("name") }}!
9+
<li><a href='/graphcall'>Call Microsoft Graph API</a></li>
10+
<li><a href="/logout">Logout</a></li>
11+
</body>
12+
</html>
13+

0 commit comments

Comments
 (0)