Skip to content

Commit b32e2d0

Browse files
committed
Add comments to all functions
1 parent 319c7bb commit b32e2d0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ippls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030

3131
def get_ip():
32+
"""Read the IP address from the current request."""
3233
try:
3334
return request.headers["X-Real-IP"]
3435
except KeyError:
@@ -37,24 +38,29 @@ def get_ip():
3738

3839
@app.route("/")
3940
def ip_html():
41+
"""Render a human-friendly homepage with the received remote IP information."""
4042
user_ip = get_ip()
4143
return render_template("index.html", user_ip=user_ip)
4244

4345

4446
@app.route("/ip.json")
4547
@app.route("/json")
4648
def ip_json():
49+
"""Return a JSON with the remote IP information."""
4750
return json.jsonify(ip=get_ip())
4851

4952

5053
@app.route("/ip.txt")
5154
@app.route("/plain")
5255
def ip_plain():
56+
"""Return only the remote IP."""
5357
return get_ip()
5458

5559

5660
@app.errorhandler(404)
5761
def page_not_found(error):
62+
"""On 404, just redirect to the homepage."""
63+
print(error)
5864
return ip_html(), 301
5965

6066

0 commit comments

Comments
 (0)