faster-app 0.0.13__tar.gz → 0.0.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {faster_app-0.0.13 → faster_app-0.0.14}/PKG-INFO +1 -1
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/__init__.py +1 -1
- faster_app-0.0.13/faster_app/commands/builtins/fastapi.py → faster_app-0.0.14/faster_app/commands/builtins/server.py +16 -4
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/PKG-INFO +1 -1
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/SOURCES.txt +1 -1
- {faster_app-0.0.13 → faster_app-0.0.14}/pyproject.toml +1 -1
- {faster_app-0.0.13 → faster_app-0.0.14}/LICENSE +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/README.md +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/.env.example +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/base.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/base.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/builtins/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/builtins/app.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/builtins/db.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/commands/discover.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/db.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/main.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/models/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/models/base.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/models/discover.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/base.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/builtins/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/builtins/defaults.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/builtins/swagger.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/routes/discover.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/settings/__init__.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/settings/builtins/settings.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/settings/discover.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/statics/swagger-ui-bundle.min.js +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/statics/swagger-ui.min.css +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/templates/apps/demo/commands.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/templates/apps/demo/models.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/templates/apps/demo/routes.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app/templates/config/settings.py +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/dependency_links.txt +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/entry_points.txt +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/requires.txt +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/faster_app.egg-info/top_level.txt +0 -0
- {faster_app-0.0.13 → faster_app-0.0.14}/setup.cfg +0 -0
@@ -1,9 +1,11 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
1
3
|
from contextlib import asynccontextmanager
|
2
4
|
from fastapi import FastAPI
|
3
5
|
from tortoise import Tortoise
|
4
|
-
from faster_app.settings.builtins.settings import DefaultSettings
|
5
6
|
from rich.console import Console
|
6
7
|
from starlette.staticfiles import StaticFiles
|
8
|
+
from faster_app.settings import configs
|
7
9
|
from faster_app.commands.base import CommandBase
|
8
10
|
from faster_app.db import tortoise_init
|
9
11
|
import uvicorn
|
@@ -39,7 +41,6 @@ class FastAPIAppSingleton:
|
|
39
41
|
def _create_app(cls):
|
40
42
|
"""创建FastAPI应用实例"""
|
41
43
|
# 创建FastAPI应用实例
|
42
|
-
configs = DefaultSettings()
|
43
44
|
app = FastAPI(
|
44
45
|
title=configs.PROJECT_NAME,
|
45
46
|
version=configs.VERSION,
|
@@ -73,13 +74,24 @@ class ServerOperations(CommandBase):
|
|
73
74
|
"""FastAPI Server Operations"""
|
74
75
|
|
75
76
|
def __init__(self, host: str = None, port: int = None):
|
76
|
-
configs = DefaultSettings()
|
77
77
|
self.host = host or configs.HOST
|
78
78
|
self.port = port or configs.PORT
|
79
79
|
self.configs = configs
|
80
80
|
|
81
81
|
def start(self):
|
82
|
-
|
82
|
+
"""start fastapi server"""
|
83
|
+
# 将当前工作目录添加到 Python 路径,确保可以导入项目模块
|
84
|
+
current_dir = os.getcwd()
|
85
|
+
if current_dir not in sys.path:
|
86
|
+
sys.path.insert(0, current_dir)
|
87
|
+
|
88
|
+
# 设置 PYTHONPATH 环境变量,确保子进程也能找到项目模块
|
89
|
+
pythonpath = os.environ.get("PYTHONPATH", "")
|
90
|
+
if current_dir not in pythonpath:
|
91
|
+
os.environ["PYTHONPATH"] = (
|
92
|
+
current_dir + ":" + pythonpath if pythonpath else current_dir
|
93
|
+
)
|
94
|
+
|
83
95
|
reload = True if self.configs.DEBUG else False
|
84
96
|
uvicorn.run(
|
85
97
|
"faster_app.commands.builtins.fastapi:app",
|
@@ -18,7 +18,7 @@ faster_app/commands/discover.py
|
|
18
18
|
faster_app/commands/builtins/__init__.py
|
19
19
|
faster_app/commands/builtins/app.py
|
20
20
|
faster_app/commands/builtins/db.py
|
21
|
-
faster_app/commands/builtins/
|
21
|
+
faster_app/commands/builtins/server.py
|
22
22
|
faster_app/models/__init__.py
|
23
23
|
faster_app/models/base.py
|
24
24
|
faster_app/models/discover.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|