Merge branch 'master' into master
This commit is contained in:
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
media/
|
media/
|
||||||
logs/
|
logs/
|
||||||
.idea
|
.idea
|
||||||
/static/upload
|
/data
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
@@ -111,7 +111,7 @@ celerybeat.pid
|
|||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
data/.env
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
@@ -150,6 +150,6 @@ for_test.py
|
|||||||
.html
|
.html
|
||||||
/evaluate/temp.py
|
/evaluate/temp.py
|
||||||
/evaluation/back.json
|
/evaluation/back.json
|
||||||
.env*
|
data/.env
|
||||||
.backup/
|
.backup/
|
||||||
/cloc-1.64.exe
|
/cloc-1.64.exe
|
||||||
|
|||||||
+1
-4
@@ -1,15 +1,12 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from alembic import command
|
from alembic import command
|
||||||
from alembic.config import Config
|
from alembic.config import Config
|
||||||
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.ext.asyncio import create_async_engine
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
|
engine = create_async_engine(settings.DATABASE_URL)
|
||||||
engine = create_async_engine(f"sqlite+aiosqlite:///{settings.DATABASE_FILE}")
|
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ app = FastAPI(debug=settings.DEBUG)
|
|||||||
DATA_ROOT = Path(settings.DATA_ROOT)
|
DATA_ROOT = Path(settings.DATA_ROOT)
|
||||||
if not DATA_ROOT.exists():
|
if not DATA_ROOT.exists():
|
||||||
DATA_ROOT.mkdir(parents=True)
|
DATA_ROOT.mkdir(parents=True)
|
||||||
# 静态文件夹
|
|
||||||
app.mount(settings.STATIC_URL, StaticFiles(directory=DATA_ROOT), name="static")
|
# 静态文件夹,这个固定就行了,静态资源都放在这里
|
||||||
|
app.mount(settings.STATIC_URL, StaticFiles(directory='./static'), name="static")
|
||||||
|
|
||||||
|
|
||||||
@app.on_event('startup')
|
@app.on_event('startup')
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ KEYWORDS=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文
|
|||||||
|
|
||||||
### Docker部署
|
### Docker部署
|
||||||
```bash
|
```bash
|
||||||
docker run -d --restart=always -v /opt/FileCodeBox/:/app -p 12345:12345 --name="filecodebox" lanol/filecodebox:V1.5.1
|
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/.env:/app/data --name filecodebox lanol/filecodebox:latest
|
||||||
```
|
```
|
||||||
### Docker自己构建部署
|
### Docker自己构建部署
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -1,15 +1,16 @@
|
|||||||
from starlette.config import Config
|
from starlette.config import Config
|
||||||
|
|
||||||
# 配置文件.env
|
# 配置文件.env
|
||||||
config = Config(".env")
|
# 请将.env移动至data目录,方便docker部署
|
||||||
|
config = Config("data/.env")
|
||||||
# 是否开启DEBUG模式
|
# 是否开启DEBUG模式
|
||||||
DEBUG = config('DEBUG', cast=bool, default=False)
|
DEBUG = config('DEBUG', cast=bool, default=False)
|
||||||
# 端口
|
# 端口
|
||||||
PORT = config('PORT', cast=int, default=12345)
|
PORT = config('PORT', cast=int, default=12345)
|
||||||
# Sqlite数据库文件
|
# Sqlite数据库文件
|
||||||
DATABASE_FILE = config('DATABASE_URL', cast=str, default="database.db")
|
DATABASE_URL = config('DATABASE_URL', cast=str, default="sqlite+aiosqlite:///data/database.db")
|
||||||
# 静态文件夹
|
# 数据存储文件夹,文件就不暴露在静态资源里面了
|
||||||
DATA_ROOT = config('DATA_ROOT', cast=str, default="./static")
|
DATA_ROOT = './data/' + config('DATA_ROOT', cast=str, default=f"static")
|
||||||
# 静态文件夹URL
|
# 静态文件夹URL
|
||||||
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
|
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
|
||||||
# 错误次数
|
# 错误次数
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ class FileSystemStorage:
|
|||||||
path = self.DATA_ROOT / f"upload/{now.year}/{now.month}/{now.day}/"
|
path = self.DATA_ROOT / f"upload/{now.year}/{now.month}/{now.day}/"
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
text = f"{self.STATIC_URL}/{(path / f'{key}.{ext}').relative_to(self.DATA_ROOT).relative_to(self.DATA_ROOT)}"
|
text = f"{self.STATIC_URL}/{(path / f'{key}.{ext}').relative_to(self.DATA_ROOT)}"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -306,8 +306,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
successUpload(response, file, fileList) {
|
successUpload(response, file, fileList) {
|
||||||
|
console.log(response)
|
||||||
this.$message({
|
this.$message({
|
||||||
message: response.msg,
|
message: response.detail,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
this.files.unshift(response.data);
|
this.files.unshift(response.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user