diff --git a/main.py b/main.py
index 58a1510..d1105f0 100644
--- a/main.py
+++ b/main.py
@@ -6,7 +6,8 @@ import random
from fastapi import FastAPI, Depends, UploadFile, Form, File
from starlette.requests import Request
-from starlette.responses import HTMLResponse
+from starlette.responses import HTMLResponse, FileResponse
+import random
from starlette.staticfiles import StaticFiles
from sqlalchemy import or_, select, update, delete, create_engine
@@ -135,6 +136,18 @@ def ip_error(ip):
return ip_info['count']
+@app.get('/select')
+async def get_file(code: str, db: Session = Depends(get_db)):
+ file = db.query(database.Codes).filter(database.Codes.code == code).first()
+ if file:
+ if file.type == 'text':
+ return {'code': code, 'msg': '查询成功', 'data': file.text}
+ else:
+ return FileResponse('.' + file.text, filename=file.name)
+ else:
+ return {'code': 404, 'msg': '口令不存在'}
+
+
@app.post('/')
async def index(request: Request, code: str, s: AsyncSession = Depends(get_session)):
ip = request.client.host
@@ -149,11 +162,13 @@ async def index(request: Request, code: str, s: AsyncSession = Depends(get_sessi
await s.delete(info)
await s.commit()
return {'code': 404, 'msg': '取件码已过期,请联系寄件人'}
-
count = info.count - 1
query = update(Codes).where(Codes.id == info.id).values(count=count)
await s.execute(query)
await s.commit()
+ if info.type != 'text':
+ info.text = f'/select?code={code}'
+
return {
'code': 200,
'msg': '取件成功,请点击"取"查看',
diff --git a/readme.md b/readme.md
index 1cafbf3..d34989e 100644
--- a/readme.md
+++ b/readme.md
@@ -15,7 +15,7 @@
- [x] 完全匿名:不记录任何信息
- [x] 无需注册:无需注册,无需登录
- [x] Sqlite3数据库:无需安装数据库
-- [x] 可以加get参数code,这样打开就会读取取件码如:http://xxx.com?code=12345
+- [x] 可以加get参数code,这样打开就会读取取件码如:http://host?code=12345
- [x] 管理面板:简单列表页删除违规文件
- [x] 口令使用次数,口令有效期,二维码分享
@@ -34,10 +34,16 @@
4. 完善配置参数
### 2022年12月10日 23:50:00
+
1. 修复取件不显示码的问题
2. 修复文件次数为1时,文件被删除的问题
+
## 系统截图
+### 2022年12月11日 14:55:00
+
+1. 隐藏文件真实地址
+
### 取件

@@ -82,7 +88,9 @@ docker run -d -p 12345:12345 --name filecodebox filecodebox
```
## 状态
+

+
## 免责声明
本项目开源仅供学习使用,不得用于商业用途以及任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
diff --git a/templates/index.html b/templates/index.html
index 8d18e3d..21e0881 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -10,7 +10,7 @@
-
+