From ffedf038b50994415f61fb594a880770b043590c Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 25 Aug 2022 17:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=9C=E7=A8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 12 ++++++++++++ templates/index.html | 1 + 2 files changed, 13 insertions(+) diff --git a/app.py b/app.py index 68be761..e93c164 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ # File : app.py # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ # Date : 2022/8/25 +import os from flask import Flask, jsonify, abort,request,redirect,make_response,render_template from js.rules import getRules @@ -86,5 +87,16 @@ def vod(): home_data = cms.homeContent() return jsonify(home_data) +@app.route('/clear') +def clear(): + rule = getParmas('rule') + if not rule: + return jsonify(error.failed('规则字段必填')) + cache_path = f'cache/{rule}.js' + if not os.path.exists(cache_path): + return jsonify(error.failed('服务端没有此规则的缓存文件!')) + os.remove(cache_path) + return jsonify(error.success('成功删除文件:'+cache_path)) + if __name__ == '__main__': app.run(host="0.0.0.0", port=9000) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index d5fa9de..9e557db 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,5 +7,6 @@

欢迎使用dr_py项目

可以简单的自定义爬虫实现cms数据接口

+缓存清理接口 \ No newline at end of file -- GitLab