Skip to content

Commit 82ba168

Browse files
committed
Fix code error for None type
1 parent e451f95 commit 82ba168

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def add_xp() -> Response: # add XP
154154
Add XP (experience points) based on entered amount.
155155
"""
156156
user: Union[User, None] = User.query.first() # get first user
157-
user.add_xp(float(request.form["amount"])) # parse amount as float
157+
if user is not None: # if user exists
158+
user.add_xp(float(request.form["amount"])) # parse amount as float
158159
db.session.commit() # commit database changes
159160
return redirect(url_for("index")) # redirect to index page template
160161

0 commit comments

Comments
 (0)