Merge branch 'master' into master

This commit is contained in:
vastsa
2022-12-11 17:18:06 +08:00
committed by GitHub
3 changed files with 27 additions and 4 deletions
+17 -2
View File
@@ -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': '取件成功,请点击""查看',
+9 -1
View File
@@ -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. 隐藏文件真实地址
### 取件
![取件](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img.png)
@@ -82,7 +88,9 @@ docker run -d -p 12345:12345 --name filecodebox filecodebox
```
## 状态
![Alt](https://repobeats.axiom.co/api/embed/7a6c92f1d96ee57e6fb67f0df371528397b0c9ac.svg "Repobeats analytics image")
## 免责声明
本项目开源仅供学习使用,不得用于商业用途以及任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
+1 -1
View File
@@ -10,7 +10,7 @@
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords}}"/>
<meta name="generator" content="FileCodeBox"/>
<meta name="template" content="Lan"/>
<meta name="template" content="Lan-V1.4.1"/>
<style>
.qu .el-button {
width: 100px;