mirror of
https://github.com/vastsa/FileCodeBox.git
synced 2026-11-21 14:37:03 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bec3eb2ea1 | ||
|
|
ae7aa63e2a | ||
|
|
b999073da4 |
No files matched your search
+2
-2
@@ -1,13 +1,13 @@
|
||||
FROM python:3.9.5
|
||||
LABEL author="Lan"
|
||||
LABEL email="vast@tom.com"
|
||||
LABEL version="1.0"
|
||||
LABEL version="1.4.2"
|
||||
|
||||
|
||||
COPY . /app
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo 'Asia/Shanghai' >/etc/timezone
|
||||
WORKDIR /app
|
||||
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
|
||||
RUN pip install -r requirements.txt
|
||||
EXPOSE 12345
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "12345"]
|
||||
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
|
||||
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
||||
@@ -10,6 +11,11 @@ engine = create_async_engine("sqlite+aiosqlite:///database.db")
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
async def init_models():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
|
||||
async def get_session():
|
||||
async with AsyncSession(engine, expire_on_commit=False) as s:
|
||||
yield s
|
||||
|
||||
@@ -11,13 +11,19 @@ from starlette.staticfiles import StaticFiles
|
||||
from sqlalchemy import or_, select, update, delete
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
|
||||
from database import get_session, Codes
|
||||
from database import get_session, Codes, init_models
|
||||
|
||||
app = FastAPI()
|
||||
if not os.path.exists('./static'):
|
||||
os.makedirs('./static')
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
|
||||
|
||||
@app.on_event('startup')
|
||||
async def startup():
|
||||
await init_models()
|
||||
|
||||
|
||||
############################################
|
||||
# 需要修改的参数
|
||||
# 允许错误次数
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta name="description" content="{{description}}"/>
|
||||
<meta name="keywords" content="{{keywords}}"/>
|
||||
<meta name="generator" content="FileCodeBox"/>
|
||||
<meta name="template" content="Lan-V1.4.1"/>
|
||||
<meta name="template" content="Lan-V1.4.2"/>
|
||||
<style>
|
||||
.qu .el-button {
|
||||
width: 100px;
|
||||
|
||||
Reference in new issue
Block a user