From 12266aed7fea6ce6bbbdcaa67701f1eaf149dc49 Mon Sep 17 00:00:00 2001 From: buxianshan <583425306@qq.com> Date: Sun, 8 Jan 2023 17:24:05 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E8=AF=B7=E6=B1=82=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index d1f3ea4..1232d4b 100644 --- a/app.py +++ b/app.py @@ -11,9 +11,6 @@ @app.route("/", methods=["GET"]) def home(): - """ - 主页 - """ return render_template("index.html") @@ -23,8 +20,6 @@ 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}) @@ -32,6 +27,12 @@ def get_icon(): 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())