diff --git a/app.py b/app.py index 68be7619c8ffc78085c2ebdaa7675fce3114d812..e93c164546c671e2591936150e966d7f6dade04a 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 d5fa9de30b6af9ca9822d54de29e02241ea95d6f..9e557dbcc59bb0d2f93d3dda91910471f2f0faa5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,5 +7,6 @@

欢迎使用dr_py项目

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

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