Skip to content

Commit b7315bb

Browse files
authored
Merge branch 'master' into master
2 parents f4e6dfe + ea64751 commit b7315bb

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

main.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from fastapi import FastAPI, Depends, UploadFile, Form, File
88
from starlette.requests import Request
9-
from starlette.responses import HTMLResponse
9+
from starlette.responses import HTMLResponse, FileResponse
10+
import random
1011
from starlette.staticfiles import StaticFiles
1112

1213
from sqlalchemy import or_, select, update, delete, create_engine
@@ -135,6 +136,18 @@ def ip_error(ip):
135136
return ip_info['count']
136137

137138

139+
@app.get('/select')
140+
async def get_file(code: str, db: Session = Depends(get_db)):
141+
file = db.query(database.Codes).filter(database.Codes.code == code).first()
142+
if file:
143+
if file.type == 'text':
144+
return {'code': code, 'msg': '查询成功', 'data': file.text}
145+
else:
146+
return FileResponse('.' + file.text, filename=file.name)
147+
else:
148+
return {'code': 404, 'msg': '口令不存在'}
149+
150+
138151
@app.post('/')
139152
async def index(request: Request, code: str, s: AsyncSession = Depends(get_session)):
140153
ip = request.client.host
@@ -149,11 +162,13 @@ async def index(request: Request, code: str, s: AsyncSession = Depends(get_sessi
149162
await s.delete(info)
150163
await s.commit()
151164
return {'code': 404, 'msg': '取件码已过期,请联系寄件人'}
152-
153165
count = info.count - 1
154166
query = update(Codes).where(Codes.id == info.id).values(count=count)
155167
await s.execute(query)
156168
await s.commit()
169+
if info.type != 'text':
170+
info.text = f'/select?code={code}'
171+
157172
return {
158173
'code': 200,
159174
'msg': '取件成功,请点击"取"查看',

readme.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [x] 完全匿名:不记录任何信息
1616
- [x] 无需注册:无需注册,无需登录
1717
- [x] Sqlite3数据库:无需安装数据库
18-
- [x] 可以加get参数code,这样打开就会读取取件码如:http://xxx.com?code=12345
18+
- [x] 可以加get参数code,这样打开就会读取取件码如:http://host?code=12345
1919
- [x] 管理面板:简单列表页删除违规文件
2020
- [x] 口令使用次数,口令有效期,二维码分享
2121

@@ -34,10 +34,16 @@
3434
4. 完善配置参数
3535

3636
### 2022年12月10日 23:50:00
37+
3738
1. 修复取件不显示码的问题
3839
2. 修复文件次数为1时,文件被删除的问题
40+
3941
## 系统截图
4042

43+
### 2022年12月11日 14:55:00
44+
45+
1. 隐藏文件真实地址
46+
4147
### 取件
4248

4349
![取件](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img.png)
@@ -82,7 +88,9 @@ docker run -d -p 12345:12345 --name filecodebox filecodebox
8288
```
8389

8490
## 状态
91+
8592
![Alt](https://repobeats.axiom.co/api/embed/7a6c92f1d96ee57e6fb67f0df371528397b0c9ac.svg "Repobeats analytics image")
93+
8694
## 免责声明
8795

8896
本项目开源仅供学习使用,不得用于商业用途以及任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。

templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="description" content="{{description}}"/>
1111
<meta name="keywords" content="{{keywords}}"/>
1212
<meta name="generator" content="FileCodeBox"/>
13-
<meta name="template" content="Lan"/>
13+
<meta name="template" content="Lan-V1.4.1"/>
1414
<style>
1515
.qu .el-button {
1616
width: 100px;

0 commit comments

Comments
 (0)