Skip to content

Commit

Permalink
feature: 请求记录日志
Browse files Browse the repository at this point in the history
  • Loading branch information
buxianshan committed Jan 8, 2023
1 parent b719c50 commit 12266ae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

@app.route("/", methods=["GET"])
def home():
"""
主页
"""
return render_template("index.html")


Expand All @@ -23,15 +20,19 @@ def get_icon():
url中需要传参: ?url={target website}
"""
url = request.args.get("url")
# if url is None:
# return jsonify({"errorMsg": "website url is null!"})
try:
icons = utils.get_icon(url)
return jsonify({"success": True, "data": icons})
except Exception as e:
return jsonify({"success": False, "data": [], "errorMsg": str(e)})


@app.before_request
def before():
if not request.path.startswith("/static"):
logger.info(f"[visited] {request.url} [remote address] {request.remote_addr}")


if __name__ == "__main__":
# 添加日志拦截器,使用loguru
app.logger.addHandler(InterceptHandler())
Expand Down

0 comments on commit 12266ae

Please sign in to comment.