update: 更新文档

This commit is contained in:
MarkusJoe
2022-09-18 09:18:11 +08:00
parent 6bbdcfc3db
commit 865161ffab
2 files changed
+8 -57

No files matched your search

+8 -6
View File
@@ -11,29 +11,31 @@
* 使用了异步Web框架`FastAPI`来提高效率 ***注:数据库部分使用了同步***
* 可以自定义显示图片的数量(长度)
* 支持API接口以便自行开发
* 支持MySQL数据库链接
> data.sql https://pac.rtst.tech/schema/counter/data.sql
> image.sql https://pac.rtst.tech/schema/counter/image.sql
* 支持MySQL数据库链接 ***程序内有默认的MySQL数据库请不要随意注水***
> sql 文件下载地址 https://pac.rtst.tech/static_file_hosting/counter/sql/
# 失去的特性
* 不支持MongoDB
* 暂未支持`MongoDB`
# 安装&运行
```bash
$ pip3 install -r requirements.txt
$ uvicorn src:create_app --factory or
$ sh run.sh or
$ python3 main.py # 两条命令等价
```
# 使用
* 访问`127.0.0.1:8000/<any name you want>`
* 访问`http://127.0.0.1:8000/<any name you want>`
> 示例: http://127.0.0.1:8000/_redirect?length=10&theme=moebooru
## 参数
* `length`
> length: 1 ≤ x ≤ 10
* `theme`
> theme: `blacked` `lewd` `lisu` `moebooru`
# 单元测试
-51
View File
@@ -1,51 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/8/30
# @File Name: convert.py
import os
import base64
import sqlite3
import asyncio
class SQLite:
def __init__(self):
self.conn = sqlite3.connect('../db/data.sqlite')
self.cursor = self.conn.cursor()
def __del__(self):
self.conn.commit()
self.cursor.close()
self.conn.close()
async def insert(self, _id: str, b64: str, width: int, height: int) -> bool:
self.cursor.execute('insert into image values ("%s", "%s", %s, %s)' % (_id, b64, width, height))
return True
async def convert():
dirs = os.listdir('../static')
for i in dirs:
files = os.listdir(f'../static/{i}')
for b in files:
with open(f'../static/{i}/{b}', 'rb') as fp:
if i == 'moebooru':
width = 45
height = 100
elif i == 'lewd':
width = 45
height = 100
elif i == 'lisu':
width = 66
height = 152
else:
width = 68
height = 150
await SQLite().insert(f'{i}/{b}', base64.b64encode(fp.read()).decode('utf-8'), width, height)
asyncio.run(convert())