Skip to content

Commit 894185a

Browse files
authored
更新fastapi启动方式 (#32)
* 更新fastapi启动方式 * 更新README
1 parent cbaba0b commit 894185a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+118
-131
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
__pycache__/
22
.idea/
3-
.env
3+
backend/.env
44
.venv/
55
venv/
6-
log/
7-
alembic/versions/
6+
backend/log/
7+
backend/alembic/versions/
88
.ruff_cache/
99
.pdm-python

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN mkdir -p /var/log/fastapi_server
2020

2121
EXPOSE 8001
2222

23-
CMD ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "8000"]
23+
CMD ["uvicorn", "backend.main:app", "--host", "127.0.0.1", "--port", "8000"]

README.md

Lines changed: 22 additions & 7 deletions

app/admin/model/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

alembic/env.py renamed to backend/alembic/env.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# ruff: noqa: E402
44
import asyncio
55
import os
6+
import sys
67
from logging.config import fileConfig
78

89
from sqlalchemy import engine_from_config
@@ -11,7 +12,9 @@
1112

1213
from alembic import context
1314

14-
from core import path_conf
15+
sys.path.append('../')
16+
17+
from backend.core import path_conf
1518

1619
if not os.path.exists(path_conf.ALEMBIC_VERSIONS_DIR):
1720
os.makedirs(path_conf.ALEMBIC_VERSIONS_DIR)
@@ -27,14 +30,14 @@
2730
# add your model's MetaData object here
2831
# for 'autogenerate' support
2932
# https://alembic.sqlalchemy.org/en/latest/autogenerate.html#autogenerating-multiple-metadata-collections
30-
from app.admin.model import MappedBase as AdminModel
33+
from backend.app.admin.model import MappedBase as AdminModel
3134

3235
target_metadata = [
3336
AdminModel.metadata,
3437
]
3538

3639
# other values from the config, defined by the needs of env.py,
37-
from database.db_mysql import SQLALCHEMY_DATABASE_URL
40+
from backend.database.db_mysql import SQLALCHEMY_DATABASE_URL
3841

3942
config.set_main_option('sqlalchemy.url', SQLALCHEMY_DATABASE_URL)
4043

0 commit comments

Comments
 (0)