隐藏真实文件地址

This commit is contained in:
lan-air
2022-12-11 14:52:28 +08:00
parent 1dc6a741b6
commit 0883eafa49
+3 -3
View File
@@ -137,14 +137,14 @@ def ip_error(ip):
return ip_info['count'] return ip_info['count']
@app.get('/file') @app.get('/select')
async def get_file(code: str, db: Session = Depends(get_db)): async def get_file(code: str, db: Session = Depends(get_db)):
file = db.query(database.Codes).filter(database.Codes.code == code).first() file = db.query(database.Codes).filter(database.Codes.code == code).first()
if file: if file:
if file.type == 'text': if file.type == 'text':
return {'code': code, 'msg': '查询成功', 'data': file.text} return {'code': code, 'msg': '查询成功', 'data': file.text}
else: else:
return FileResponse('.' + file.text) return FileResponse('.' + file.text, filename=file.name)
else: else:
return {'code': 404, 'msg': '口令不存在'} return {'code': 404, 'msg': '口令不存在'}
@@ -165,7 +165,7 @@ async def index(request: Request, code: str, db: Session = Depends(get_db)):
info.count -= 1 info.count -= 1
db.commit() db.commit()
if info.type != 'text': if info.type != 'text':
info.text = f'/file?code={code}' info.text = f'/select?code={code}'
return { return {
'code': 200, 'code': 200,
'msg': '取件成功,请点击""查看', 'msg': '取件成功,请点击""查看',