diff --git a/blueprints/api.py b/blueprints/api.py index 660b6ac..0432df3 100644 --- a/blueprints/api.py +++ b/blueprints/api.py @@ -40,7 +40,6 @@ def help(): "/time": "Get the current time", "/timezone": "Get the current timezone", "/message": "Get the message from the config", - "/ip": "Get your IP address", "/project": "Get the current project from git", "/version": "Get the current version of the website", "/page_date?url=URL&verbose=BOOL": "Get the last modified date of a webpage (verbose is optional, default false)", @@ -48,6 +47,8 @@ def help(): "/playing": "Get the currently playing Spotify track", "/status": "Just check if the site is up", "/ping": "Just check if the site is up", + "/ip": "Get your IP address", + "/headers": "Get your request headers", "/help": "Get this help message" }, "base_url": "/api/v1", @@ -191,6 +192,17 @@ def playing(): return json_response(request, track_info, HTTP_OK) return json_response(request, {"spotify": track_info}, HTTP_OK) + +@api_bp.route("/headers") +def headers(): + """Get the request headers.""" + headers = dict(request.headers) + return jsonify({ + "headers": headers, + "ip": getClientIP(request), + "status": HTTP_OK + }) + @api_bp.route("/page_date") def page_date(): url = request.args.get("url")