Skip to content

Commit 86fe69f

Browse files
authored
updates '/' route to handle keyError (#21)
* updates '/' route to handle keyError Right now, if you haven't used the application, the, if condition to check session["raw_profile"], throws a keyError as the session key doesn't exist yet. Setting it to a try with an except should handle this * Update app.py
1 parent 800f540 commit 86fe69f

File tree

1 file changed

+2
-3
lines changed
  • python-flask-sso-example

1 file changed

+2
-3
lines changed

python-flask-sso-example/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ def to_pretty_json(value):
2727

2828
app.jinja_env.filters["tojson_pretty"] = to_pretty_json
2929

30-
3130
@app.route("/")
3231
def login():
33-
if session["raw_profile"]:
32+
try:
3433
return render_template(
3534
"login_successful.html",
3635
first_name=session["first_name"],
3736
raw_profile=session["raw_profile"],
3837
)
39-
else:
38+
except KeyError:
4039
return render_template("login.html")
4140

4241

0 commit comments

Comments
 (0)