Archived
update: Update
This commit is contained in:
2 files changed
+8
-8
No files matched your search
+4
-4
@@ -7,19 +7,19 @@
|
|||||||
|
|
||||||
|
|
||||||
from src.api import api
|
from src.api import api
|
||||||
from src.db import SQLite
|
from src.db import Database
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
|
|
||||||
|
|
||||||
@api.get('/query/{name}')
|
@api.get('/query/{name}')
|
||||||
async def query(name: str):
|
async def query(name: str):
|
||||||
times = SQLite().query(name)[1]
|
times = Database().query(name)[1]
|
||||||
return {name: times}
|
return {name: times}
|
||||||
|
|
||||||
|
|
||||||
@api.get('/query-all/')
|
@api.get('/query-all/')
|
||||||
async def query_all(limit: int = 30):
|
async def query_all(limit: int = 30):
|
||||||
data = SQLite().query_all()[:limit]
|
data = Database().query_all()[:limit]
|
||||||
result = {}
|
result = {}
|
||||||
for i in data:
|
for i in data:
|
||||||
result[i[0]] = i[1]
|
result[i[0]] = i[1]
|
||||||
@@ -35,6 +35,6 @@ async def export():
|
|||||||
async def query_theme(name: str):
|
async def query_theme(name: str):
|
||||||
themes = []
|
themes = []
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
data = SQLite().query_image(name + '/' + str(i))[0]
|
data = Database().query_image(name + '/' + str(i))[0]
|
||||||
themes.append(data)
|
themes.append(data)
|
||||||
return themes
|
return themes
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
# @File Name: response.py
|
# @File Name: response.py
|
||||||
|
|
||||||
|
|
||||||
from src.db import SQLite
|
from src.db import Database
|
||||||
|
|
||||||
|
|
||||||
async def resp(_id: str, length: int = 7, theme: str = 'lewd') -> dict:
|
async def resp(_id: str, length: int = 7, theme: str = 'lewd') -> dict:
|
||||||
@@ -17,16 +17,16 @@ async def resp(_id: str, length: int = 7, theme: str = 'lewd') -> dict:
|
|||||||
:param theme:
|
:param theme:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
times = SQLite().query(_id)[1]
|
times = Database().query(_id)[1]
|
||||||
str_number = str(times) # 将整形转换为字符串
|
str_number = str(times) # 将整形转换为字符串
|
||||||
len_number = len(str_number) # 再获取字符串长度
|
len_number = len(str_number) # 再获取字符串长度
|
||||||
g_length = length * '0' # 根据输入的位数来自动生成0的数量
|
g_length = length * '0' # 根据输入的位数来自动生成0的数量
|
||||||
show_number = str(g_length[:-len_number] + str_number)
|
show_number = str(g_length[:-len_number] + str_number)
|
||||||
context = []
|
context = []
|
||||||
w_h = SQLite().query_image(theme + '/0')[0]
|
w_h = Database().query_image(theme + '/0')[0]
|
||||||
count = 0 # 计数器, 每次遍历一次则加一, 让图片x轴相乘
|
count = 0 # 计数器, 每次遍历一次则加一, 让图片x轴相乘
|
||||||
for i in show_number:
|
for i in show_number:
|
||||||
data = SQLite().query_image(theme + '/' + i)[0]
|
data = Database().query_image(theme + '/' + i)[0]
|
||||||
context.append({'position': data[-2] * count,
|
context.append({'position': data[-2] * count,
|
||||||
'width': data[-2],
|
'width': data[-2],
|
||||||
'height': data[-1],
|
'height': data[-1],
|
||||||
|
|||||||
Reference in New Issue
Block a user