Skip to content

Commit 63d6002

Browse files
authored
Merge branch 'master' into master
2 parents 8ffddd5 + 1e2d83a commit 63d6002

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
media/
22
logs/
33
.idea
4-
/static/upload
4+
/data
55
__pycache__/
66
*.py[cod]
77
*$py.class
@@ -111,7 +111,7 @@ celerybeat.pid
111111
*.sage.py
112112

113113
# Environments
114-
.env
114+
data/.env
115115
.venv
116116
env/
117117
venv/
@@ -150,6 +150,6 @@ for_test.py
150150
.html
151151
/evaluate/temp.py
152152
/evaluation/back.json
153-
.env*
153+
data/.env
154154
.backup/
155155
/cloc-1.64.exe

database.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import datetime
2-
32
from alembic import command
43
from alembic.config import Config
54
from sqlalchemy import Boolean, Column, Integer, String, DateTime
65
from sqlalchemy.ext.declarative import declarative_base
76
from sqlalchemy.ext.asyncio import create_async_engine
87
from sqlalchemy.ext.asyncio.session import AsyncSession
9-
108
import settings
11-
12-
engine = create_async_engine(f"sqlite+aiosqlite:///{settings.DATABASE_FILE}")
9+
engine = create_async_engine(settings.DATABASE_URL)
1310

1411
Base = declarative_base()
1512

main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
DATA_ROOT = Path(settings.DATA_ROOT)
2323
if not DATA_ROOT.exists():
2424
DATA_ROOT.mkdir(parents=True)
25-
# 静态文件夹
26-
app.mount(settings.STATIC_URL, StaticFiles(directory=DATA_ROOT), name="static")
25+
26+
# 静态文件夹,这个固定就行了,静态资源都放在这里
27+
app.mount(settings.STATIC_URL, StaticFiles(directory='./static'), name="static")
2728

2829

2930
@app.on_event('startup')

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ KEYWORDS=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文
119119

120120
### Docker部署
121121
```bash
122-
docker run -d --restart=always -v /opt/FileCodeBox/:/app -p 12345:12345 --name="filecodebox" lanol/filecodebox:V1.5.1
122+
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/.env:/app/data --name filecodebox lanol/filecodebox:latest
123123
```
124124
### Docker自己构建部署
125125

settings.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from starlette.config import Config
22

33
# 配置文件.env
4-
config = Config(".env")
4+
# 请将.env移动至data目录,方便docker部署
5+
config = Config("data/.env")
56
# 是否开启DEBUG模式
67
DEBUG = config('DEBUG', cast=bool, default=False)
78
# 端口
89
PORT = config('PORT', cast=int, default=12345)
910
# Sqlite数据库文件
10-
DATABASE_FILE = config('DATABASE_URL', cast=str, default="database.db")
11-
# 静态文件夹
12-
DATA_ROOT = config('DATA_ROOT', cast=str, default="./static")
11+
DATABASE_URL = config('DATABASE_URL', cast=str, default="sqlite+aiosqlite:///data/database.db")
12+
# 数据存储文件夹,文件就不暴露在静态资源里面了
13+
DATA_ROOT = './data/' + config('DATA_ROOT', cast=str, default=f"static")
1314
# 静态文件夹URL
1415
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
1516
# 错误次数

storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def get_text(self, file: UploadFile, key: str):
2323
path = self.DATA_ROOT / f"upload/{now.year}/{now.month}/{now.day}/"
2424
if not path.exists():
2525
path.mkdir(parents=True)
26-
text = f"{self.STATIC_URL}/{(path / f'{key}.{ext}').relative_to(self.DATA_ROOT).relative_to(self.DATA_ROOT)}"
26+
text = f"{self.STATIC_URL}/{(path / f'{key}.{ext}').relative_to(self.DATA_ROOT)}"
2727
return text
2828

2929
@staticmethod

templates/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@
306306
}
307307
},
308308
successUpload(response, file, fileList) {
309+
console.log(response)
309310
this.$message({
310-
message: response.msg,
311+
message: response.detail,
311312
type: 'success'
312313
});
313314
this.files.unshift(response.data);

0 commit comments

Comments
 (0)