Skip to content

Commit e983cc9

Browse files
committed
Fix spelling and add some comments
1 parent 29805dd commit e983cc9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def check_level_up(self): # check if user has leveled up
4242
self.xp -= self.xp_required
4343
self.xp_required = round(
4444
self.xp_required + self.xp_required * 1 / math.sqrt(self.level)
45-
)
45+
) # increase XP required exponentially with slower growth at higher levels
4646
self.level += 1 # increase level
4747

4848
def get_xp_required(self): # get required XP to next level
@@ -107,7 +107,7 @@ def index(): # get index page template
107107
Return the index page containing a user.
108108
"""
109109
user = User.query.first() # get first user
110-
return render_template("index.html", user=user) # return index page template
110+
return render_template("index.html", user=user) # redirect to index page template
111111

112112

113113
@app.route("/add_xp", methods=["POST"]) # add XP from POST method
@@ -118,21 +118,21 @@ def add_xp(): # add XP
118118
user = User.query.first() # get first user
119119
user.add_xp(float(request.form["amount"])) # parse amount as float
120120
db.session.commit() # commit database changes
121-
return redirect(url_for("index")) # return index page template
121+
return redirect(url_for("index")) # redirect to index page template
122122

123123

124124
def init_db(): # initialize database
125125
"""
126126
Initialize the user database.
127127
"""
128128
with app.app_context():
129-
db.create_all() # initialize database
129+
db.create_all() # create tables if they don't exist
130130
if User.query.count() == 0: # if there is no user in database
131131
new_user = User(username="Player") # add user with name 'Player'
132132
db.session.add(new_user) # add new user to database
133133
db.session.commit() # commit database changes
134134

135135

136136
if __name__ == "__main__":
137-
init_db()
138-
app.run(debug=True, port=8081) # run the app at post 8081
137+
init_db() # initialize database
138+
app.run(debug=True, port=8081) # run the app at port 8081

0 commit comments

Comments
 (0)