Archived
修复无法使用的bug
This commit is contained in:
5 files changed
+23
-13
No files matched your search
@@ -93,7 +93,17 @@ def error(reason) -> Response:
|
|||||||
return jsonify({'code': 500, 'msg': '服务器内部错误', 'data': None})
|
return jsonify({'code': 500, 'msg': '服务器内部错误', 'data': None})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get/log', methods=['GET', 'POST'])
|
@app.route('/extra/db')
|
||||||
|
def export_db():
|
||||||
|
"""
|
||||||
|
导出数据库
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
dir_path = os.path.join(app.root_path, 'bin/db')
|
||||||
|
return send_from_directory(dir_path, 'count.db', as_attachment=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/extra/log', methods=['GET', 'POST'])
|
||||||
def view_log() -> Response:
|
def view_log() -> Response:
|
||||||
"""
|
"""
|
||||||
下载日志
|
下载日志
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
import os
|
import os
|
||||||
from bin.utils.logger import logger
|
from bin.utils.logger import logger
|
||||||
|
|
||||||
if not os.path.exists('./db/count.db'):
|
if not os.path.exists('./bin/db/count.db'):
|
||||||
logger.error('未检测到用户计数数据库')
|
logger.error('未检测到用户计数数据库')
|
||||||
import sqlite3
|
import sqlite3
|
||||||
conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
|
conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Check:
|
|||||||
检验本地文件md5是否和远程md5相同
|
检验本地文件md5是否和远程md5相同
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
with open('./db/style.db', 'rb') as fp:
|
with open('./bin/db/style.db', 'rb') as fp:
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
local_md5 = hashlib.md5(data).hexdigest()
|
local_md5 = hashlib.md5(data).hexdigest()
|
||||||
remote_md5 = self.session.get(self.remote_md5).json()['data'][0]
|
remote_md5 = self.session.get(self.remote_md5).json()['data'][0]
|
||||||
@@ -84,9 +84,9 @@ class Check:
|
|||||||
mtd_list = []
|
mtd_list = []
|
||||||
start = 0
|
start = 0
|
||||||
end = -1
|
end = -1
|
||||||
with open('./db/style.db', 'w') as initial_file:
|
with open('./bin/db/style.db', 'w') as initial_file:
|
||||||
initial_file.close()
|
initial_file.close()
|
||||||
with open('./db/style.db', 'rb+') as f:
|
with open('./bin/db/style.db', 'rb+') as f:
|
||||||
name = 1
|
name = 1
|
||||||
fileno = f.fileno()
|
fileno = f.fileno()
|
||||||
while end < filesize - 1:
|
while end < filesize - 1:
|
||||||
@@ -115,10 +115,10 @@ class Check:
|
|||||||
session.trust_env = False
|
session.trust_env = False
|
||||||
logger.info(f'正在使用单线程下载中')
|
logger.info(f'正在使用单线程下载中')
|
||||||
resp = session.get(self.assets_url)
|
resp = session.get(self.assets_url)
|
||||||
with open('./db/style.db', 'wb') as fp:
|
with open('./bin/db/style.db', 'wb') as fp:
|
||||||
fp.write(resp.content)
|
fp.write(resp.content)
|
||||||
logger.info('下载完成 正在检验文件md5')
|
logger.info('下载完成 正在检验文件md5')
|
||||||
with open('./db/style.db', 'rb') as fp:
|
with open('./bin/db/style.db', 'rb') as fp:
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
local_md5 = hashlib.md5(data).hexdigest()
|
local_md5 = hashlib.md5(data).hexdigest()
|
||||||
remote_md5 = session.get('https://themedatabases.vercel.app/md5').json()['data'][0]
|
remote_md5 = session.get('https://themedatabases.vercel.app/md5').json()['data'][0]
|
||||||
@@ -132,7 +132,7 @@ class Check:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ != '__main__':
|
if __name__ != '__main__':
|
||||||
__all__ = ['b64img', 'error', 'logger', 'view']
|
__all__ = ['error', 'logger', 'view']
|
||||||
if not os.path.exists('./db/style.db'):
|
if not os.path.exists('./bin/db/style.db'):
|
||||||
logger.error('没有检测到本地主题数据库即将开始下载')
|
logger.error('没有检测到本地主题数据库即将开始下载')
|
||||||
Check().download()
|
Check().download()
|
||||||
+2
-2
@@ -9,14 +9,14 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from bin.db import (update_data, fetch_table)
|
from bin.db.sqlite import (update_data, fetch_table)
|
||||||
|
|
||||||
|
|
||||||
class ErrorProcess:
|
class ErrorProcess:
|
||||||
"""处理错误的页面"""
|
"""处理错误的页面"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.msg_template = {'code': -2,
|
self.msg_template = {'code': -2,
|
||||||
'msg': '',
|
'msg': Optional[str],
|
||||||
'data': Optional[list]}
|
'data': Optional[list]}
|
||||||
|
|
||||||
def get_theme_list(self) -> Response:
|
def get_theme_list(self) -> Response:
|
||||||
|
|||||||
+2
-2
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
|
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from bin.db import fetch_style_data
|
from bin.db.sqlite import fetch_style_data
|
||||||
from bin.db import fetch_table
|
from bin.db.sqlite import fetch_table
|
||||||
|
|
||||||
|
|
||||||
def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, str]:
|
def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user