feat: 添加图像服务接口以提供截图访问功能并更新报告状态链接
This commit is contained in:
parent
11bd09e281
commit
3aee8f4033
@ -16,7 +16,7 @@ while True:
|
|||||||
logger.logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
logger.logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
||||||
try:
|
try:
|
||||||
info = d.process_ticket(li['name_title'], li['link'])
|
info = d.process_ticket(li['name_title'], li['link'])
|
||||||
db.update_fight_record_status(li['id'], 2, info)
|
db.update_fight_record_status(li['id'], 2, f"http://123.58.197.91:5000/image/{info}")
|
||||||
db.flush()
|
db.flush()
|
||||||
time.sleep(5 * 60)
|
time.sleep(5 * 60)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
from flask import Flask, send_file, abort
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# 固定 screenshots 目录
|
||||||
|
PROJECT_ROOT = Path(__file__).parent.resolve()
|
||||||
|
SCREENSHOTS_DIR = PROJECT_ROOT / "screenshots"
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/image/<path:filename>')
|
||||||
|
def serve_image(filename):
|
||||||
|
file_path = SCREENSHOTS_DIR / filename
|
||||||
|
|
||||||
|
# 防止路径越界访问
|
||||||
|
try:
|
||||||
|
file_path.resolve().relative_to(SCREENSHOTS_DIR.resolve())
|
||||||
|
except ValueError:
|
||||||
|
abort(403, "禁止访问目录外文件")
|
||||||
|
|
||||||
|
if not file_path.exists():
|
||||||
|
abort(404, "文件不存在")
|
||||||
|
|
||||||
|
return send_file(file_path, as_attachment=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', debug=False, port=5000)
|
Loading…
x
Reference in New Issue
Block a user