From 1dc6a741b67ebdf8ff47860509d23ad5041d589d Mon Sep 17 00:00:00 2001 From: lan-air Date: Sun, 11 Dec 2022 14:40:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 14e6c2f..64723a1 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ from fastapi import FastAPI, Depends, UploadFile, Form, File from sqlalchemy import or_ from sqlalchemy.orm import Session from starlette.requests import Request -from starlette.responses import HTMLResponse +from starlette.responses import HTMLResponse, FileResponse import random from starlette.staticfiles import StaticFiles @@ -137,6 +137,18 @@ def ip_error(ip): return ip_info['count'] +@app.get('/file') +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) + else: + return {'code': 404, 'msg': '口令不存在'} + + @app.post('/') async def index(request: Request, code: str, db: Session = Depends(get_db)): ip = request.client.host @@ -152,6 +164,8 @@ async def index(request: Request, code: str, db: Session = Depends(get_db)): return {'code': 404, 'msg': '取件码已过期,请联系寄件人'} info.count -= 1 db.commit() + if info.type != 'text': + info.text = f'/file?code={code}' return { 'code': 200, 'msg': '取件成功,请点击"取"查看', From 0883eafa49025b877d68165f89efa20919cd38df Mon Sep 17 00:00:00 2001 From: lan-air Date: Sun, 11 Dec 2022 14:52:28 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 64723a1..60fe851 100644 --- a/main.py +++ b/main.py @@ -137,14 +137,14 @@ def ip_error(ip): return ip_info['count'] -@app.get('/file') +@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) + return FileResponse('.' + file.text, filename=file.name) else: return {'code': 404, 'msg': '口令不存在'} @@ -165,7 +165,7 @@ async def index(request: Request, code: str, db: Session = Depends(get_db)): info.count -= 1 db.commit() if info.type != 'text': - info.text = f'/file?code={code}' + info.text = f'/select?code={code}' return { 'code': 200, 'msg': '取件成功,请点击"取"查看', From ff831e39f4fe8aad7f9a256f1ccca909a07ed38d Mon Sep 17 00:00:00 2001 From: lan-air Date: Sun, 11 Dec 2022 14:55:29 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index 1cafbf3..cac0c97 100644 --- a/readme.md +++ b/readme.md @@ -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") + ## 免责声明 本项目开源仅供学习使用,不得用于商业用途以及任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。 From dd39423d1a9a30db5afb5190eb47eb1280c417be Mon Sep 17 00:00:00 2001 From: lan-air Date: Sun, 11 Dec 2022 15:04:38 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ - +