提交 f2c8e4e7 编写于 作者: H hjdhnx

增加了自定义文件路由

上级 e714163e
......@@ -15,5 +15,6 @@
"filterable":0
}
],
"spider": "{{ host }}/files/custom_spider.jar",
"lives":[{"group":"redirect","channels":[{"name":"我的直播","urls":["proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvemIudHh0"]}]}],
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
import json
import os
from flask import Blueprint,abort,render_template,url_for,redirect,make_response
from flask import Blueprint,abort,render_template,render_template_string,url_for,redirect,make_response
from controllers.service import storage_service
from controllers.classes import getClasses,getClassInfo
from utils.web import getParmas
......@@ -95,6 +95,23 @@ def plugin(name):
except Exception as e:
return R.failed(f'非法猥亵\n{e}')
@home.route('/files/<name>')
def get_files(name):
base_path = 'base/files'
os.makedirs(base_path,exist_ok=True)
file_path = os.path.join(base_path, f'{name}')
if not os.path.exists(file_path):
return R.failed(f'{file_path}文件不存在')
with open(file_path, mode='rb') as f:
file_byte = f.read()
response = make_response(file_byte)
filename = name
response.headers['Content-Type'] = 'application/octet-stream'
response.headers['Content-Disposition'] = f'attachment;filename="{filename}"'
return response
@home.route('/lives')
def get_lives():
live_path = 'js/直播.txt'
......@@ -131,17 +148,17 @@ def config_render(mode):
with open(customFile,'w+',encoding='utf-8') as f:
f.write('{}')
customConfig = False
try:
with open(customFile,'r',encoding='utf-8') as f:
customConfig = parseText(f.read())
except Exception as e:
logger.info(f'用户自定义配置加载失败:{e}')
if mode == 1:
jyw_ip = getHost(mode)
logger.info(jyw_ip)
new_conf = cfg
host = getHost(mode)
try:
with open(customFile,'r',encoding='utf-8') as f:
text = f.read()
customConfig = parseText(render_template_string(text,host=host))
except Exception as e:
logger.info(f'用户自定义配置加载失败:{e}')
jxs = getJxs()
alists = getAlist()
alists_str = json.dumps(alists, ensure_ascii=False)
......
3.3.1
\ No newline at end of file
3.3.2
\ No newline at end of file
......@@ -49,6 +49,7 @@
###### 2022/09/08
- [X] 1.升级到3.2.9,支持自动合并自定义用户配置(内置t4测试源)
- [X] 7.升级到3.3.0,增加奇珍异兽源
- [X] 7.升级到3.3.2,增加自定义本地文件路由: {{ host }}/files/文件名 比如 {{ host }}/files/custom_spider.jar
###### 2022/09/07
- [X] 1.优化后台管理登录界面,升级更新脚本
- [X] 2.增加了镜像合并脚本(三合一直接拉 hjdhnx/drpy 即可)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册