提交 ffedf038 编写于 作者: H hjdhnx

增加远程文件支持

上级 a8f27381
......@@ -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
......@@ -7,5 +7,6 @@
<body>
<h1>欢迎使用dr_py项目</h1>
<p>可以简单的自定义爬虫实现cms数据接口</p>
<a href="/clear?rule=">缓存清理接口</a>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册