faster-app 0.0.14__tar.gz → 0.0.15__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.14 → faster_app-0.0.15}/PKG-INFO +1 -28
- {faster_app-0.0.14 → faster_app-0.0.15}/README.md +0 -27
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/__init__.py +1 -1
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/base.py +19 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/builtins/db.py +1 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/builtins/server.py +2 -16
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/PKG-INFO +1 -28
- {faster_app-0.0.14 → faster_app-0.0.15}/pyproject.toml +1 -1
- {faster_app-0.0.14 → faster_app-0.0.15}/LICENSE +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/.env.example +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/base.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/builtins/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/builtins/app.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/commands/discover.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/db.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/main.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/models/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/models/base.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/models/discover.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/base.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/builtins/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/builtins/defaults.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/builtins/swagger.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/routes/discover.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/settings/__init__.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/settings/builtins/settings.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/settings/discover.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/statics/swagger-ui-bundle.min.js +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/statics/swagger-ui.min.css +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/templates/apps/demo/commands.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/templates/apps/demo/models.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/templates/apps/demo/routes.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app/templates/config/settings.py +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/SOURCES.txt +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/dependency_links.txt +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/entry_points.txt +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/requires.txt +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/faster_app.egg-info/top_level.txt +0 -0
- {faster_app-0.0.14 → faster_app-0.0.15}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: faster_app
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.15
|
4
4
|
Summary: 一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能
|
5
5
|
Author-email: peizhenfei <peizhenfei@hotmail.com>
|
6
6
|
Maintainer-email: peizhenfei <peizhenfei@hotmail.com>
|
@@ -25,11 +25,6 @@ Dynamic: license-file
|
|
25
25
|
|
26
26
|
# Faster APP
|
27
27
|
|
28
|
-
[](https://www.python.org/downloads/)
|
29
|
-
[](https://fastapi.tiangolo.com/)
|
30
|
-
[](https://tortoise.github.io/)
|
31
|
-
[](https://opensource.org/licenses/MIT)
|
32
|
-
|
33
28
|
一个轻量级、高性能的 Python Web 框架,基于 FastAPI 和 Tortoise ORM 构建,提供自动发现、模型基类、命令行工具等企业级功能。
|
34
29
|
|
35
30
|
## ✨ 核心特性
|
@@ -65,7 +60,6 @@ your-project/
|
|
65
60
|
│ └── commands.py
|
66
61
|
├── config/
|
67
62
|
└──── settings.py # 配置文件
|
68
|
-
└── main.py # 入口文件
|
69
63
|
```
|
70
64
|
|
71
65
|
### 2. 模型定义
|
@@ -135,24 +129,6 @@ class UserCommand(CommandBase):
|
|
135
129
|
print(f" - {user.name} ({user.email})")
|
136
130
|
```
|
137
131
|
|
138
|
-
### 5. 启动应用
|
139
|
-
|
140
|
-
```python
|
141
|
-
# main.py
|
142
|
-
import fire
|
143
|
-
from faster_app.commands.discover import CommandDiscover
|
144
|
-
|
145
|
-
if __name__ == "__main__":
|
146
|
-
# 自动发现并注册所有命令
|
147
|
-
command_instances = CommandDiscover().discover()
|
148
|
-
commands = {}
|
149
|
-
for instance in command_instances:
|
150
|
-
command_name = instance.get_command_name()
|
151
|
-
commands[command_name] = instance
|
152
|
-
|
153
|
-
fire.Fire(commands)
|
154
|
-
```
|
155
|
-
|
156
132
|
# 🛠️ 内置工具
|
157
133
|
|
158
134
|
### 1. 数据库管理
|
@@ -219,9 +195,6 @@ class Settings(BaseSettings):
|
|
219
195
|
DB_USER: str = "postgres"
|
220
196
|
DB_PASSWORD: str = "password"
|
221
197
|
DB_DATABASE: str = "mydb"
|
222
|
-
|
223
|
-
# 实例化配置
|
224
|
-
configs = Settings()
|
225
198
|
```
|
226
199
|
|
227
200
|
### 环境变量支持
|
@@ -1,10 +1,5 @@
|
|
1
1
|
# Faster APP
|
2
2
|
|
3
|
-
[](https://www.python.org/downloads/)
|
4
|
-
[](https://fastapi.tiangolo.com/)
|
5
|
-
[](https://tortoise.github.io/)
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
7
|
-
|
8
3
|
一个轻量级、高性能的 Python Web 框架,基于 FastAPI 和 Tortoise ORM 构建,提供自动发现、模型基类、命令行工具等企业级功能。
|
9
4
|
|
10
5
|
## ✨ 核心特性
|
@@ -40,7 +35,6 @@ your-project/
|
|
40
35
|
│ └── commands.py
|
41
36
|
├── config/
|
42
37
|
└──── settings.py # 配置文件
|
43
|
-
└── main.py # 入口文件
|
44
38
|
```
|
45
39
|
|
46
40
|
### 2. 模型定义
|
@@ -110,24 +104,6 @@ class UserCommand(CommandBase):
|
|
110
104
|
print(f" - {user.name} ({user.email})")
|
111
105
|
```
|
112
106
|
|
113
|
-
### 5. 启动应用
|
114
|
-
|
115
|
-
```python
|
116
|
-
# main.py
|
117
|
-
import fire
|
118
|
-
from faster_app.commands.discover import CommandDiscover
|
119
|
-
|
120
|
-
if __name__ == "__main__":
|
121
|
-
# 自动发现并注册所有命令
|
122
|
-
command_instances = CommandDiscover().discover()
|
123
|
-
commands = {}
|
124
|
-
for instance in command_instances:
|
125
|
-
command_name = instance.get_command_name()
|
126
|
-
commands[command_name] = instance
|
127
|
-
|
128
|
-
fire.Fire(commands)
|
129
|
-
```
|
130
|
-
|
131
107
|
# 🛠️ 内置工具
|
132
108
|
|
133
109
|
### 1. 数据库管理
|
@@ -194,9 +170,6 @@ class Settings(BaseSettings):
|
|
194
170
|
DB_USER: str = "postgres"
|
195
171
|
DB_PASSWORD: str = "password"
|
196
172
|
DB_DATABASE: str = "mydb"
|
197
|
-
|
198
|
-
# 实例化配置
|
199
|
-
configs = Settings()
|
200
173
|
```
|
201
174
|
|
202
175
|
### 环境变量支持
|
@@ -3,6 +3,7 @@
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
import os
|
6
|
+
import sys
|
6
7
|
import inspect
|
7
8
|
from functools import wraps
|
8
9
|
from tortoise import Tortoise
|
@@ -43,6 +44,24 @@ class CommandBase(object):
|
|
43
44
|
"Operation",
|
44
45
|
]
|
45
46
|
|
47
|
+
def __init__(self):
|
48
|
+
"""初始化命令基类,自动配置 PYTHONPATH"""
|
49
|
+
self._setup_python_path()
|
50
|
+
|
51
|
+
def _setup_python_path(self):
|
52
|
+
"""配置 Python 路径,确保可以导入项目模块"""
|
53
|
+
# 将当前工作目录添加到 Python 路径,确保可以导入项目模块
|
54
|
+
current_dir = os.getcwd()
|
55
|
+
if current_dir not in sys.path:
|
56
|
+
sys.path.insert(0, current_dir)
|
57
|
+
|
58
|
+
# 设置 PYTHONPATH 环境变量,确保子进程也能找到项目模块
|
59
|
+
pythonpath = os.environ.get("PYTHONPATH", "")
|
60
|
+
if current_dir not in pythonpath:
|
61
|
+
os.environ["PYTHONPATH"] = (
|
62
|
+
current_dir + ":" + pythonpath if pythonpath else current_dir
|
63
|
+
)
|
64
|
+
|
46
65
|
def __getattribute__(self, name):
|
47
66
|
"""自动为异步方法添加数据库初始化装饰器"""
|
48
67
|
attr = object.__getattribute__(self, name)
|
@@ -16,6 +16,7 @@ class DBOperations(CommandBase):
|
|
16
16
|
"""DB Operations - 使用 Aerich 管理数据库迁移"""
|
17
17
|
|
18
18
|
def __init__(self, fake: bool = False):
|
19
|
+
super().__init__() # 调用父类初始化,自动配置 PYTHONPATH
|
19
20
|
self.fake = fake
|
20
21
|
self.command = Command(
|
21
22
|
tortoise_config=self._get_tortoise_config(), app="aerich"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import os
|
2
|
-
import sys
|
3
2
|
from contextlib import asynccontextmanager
|
4
3
|
from fastapi import FastAPI
|
5
4
|
from tortoise import Tortoise
|
@@ -52,8 +51,6 @@ class FastAPIAppSingleton:
|
|
52
51
|
|
53
52
|
# 添加静态文件服务器
|
54
53
|
try:
|
55
|
-
import os
|
56
|
-
|
57
54
|
static_dir = os.path.join(os.path.dirname(__file__), "..", "..", "statics")
|
58
55
|
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
59
56
|
except Exception as e:
|
@@ -74,27 +71,16 @@ class ServerOperations(CommandBase):
|
|
74
71
|
"""FastAPI Server Operations"""
|
75
72
|
|
76
73
|
def __init__(self, host: str = None, port: int = None):
|
74
|
+
super().__init__() # 调用父类初始化,自动配置 PYTHONPATH
|
77
75
|
self.host = host or configs.HOST
|
78
76
|
self.port = port or configs.PORT
|
79
77
|
self.configs = configs
|
80
78
|
|
81
79
|
def start(self):
|
82
80
|
"""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
|
-
|
95
81
|
reload = True if self.configs.DEBUG else False
|
96
82
|
uvicorn.run(
|
97
|
-
"faster_app.commands.builtins.
|
83
|
+
"faster_app.commands.builtins.server:app",
|
98
84
|
host=self.host,
|
99
85
|
port=self.port,
|
100
86
|
reload=reload,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: faster_app
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.15
|
4
4
|
Summary: 一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能
|
5
5
|
Author-email: peizhenfei <peizhenfei@hotmail.com>
|
6
6
|
Maintainer-email: peizhenfei <peizhenfei@hotmail.com>
|
@@ -25,11 +25,6 @@ Dynamic: license-file
|
|
25
25
|
|
26
26
|
# Faster APP
|
27
27
|
|
28
|
-
[](https://www.python.org/downloads/)
|
29
|
-
[](https://fastapi.tiangolo.com/)
|
30
|
-
[](https://tortoise.github.io/)
|
31
|
-
[](https://opensource.org/licenses/MIT)
|
32
|
-
|
33
28
|
一个轻量级、高性能的 Python Web 框架,基于 FastAPI 和 Tortoise ORM 构建,提供自动发现、模型基类、命令行工具等企业级功能。
|
34
29
|
|
35
30
|
## ✨ 核心特性
|
@@ -65,7 +60,6 @@ your-project/
|
|
65
60
|
│ └── commands.py
|
66
61
|
├── config/
|
67
62
|
└──── settings.py # 配置文件
|
68
|
-
└── main.py # 入口文件
|
69
63
|
```
|
70
64
|
|
71
65
|
### 2. 模型定义
|
@@ -135,24 +129,6 @@ class UserCommand(CommandBase):
|
|
135
129
|
print(f" - {user.name} ({user.email})")
|
136
130
|
```
|
137
131
|
|
138
|
-
### 5. 启动应用
|
139
|
-
|
140
|
-
```python
|
141
|
-
# main.py
|
142
|
-
import fire
|
143
|
-
from faster_app.commands.discover import CommandDiscover
|
144
|
-
|
145
|
-
if __name__ == "__main__":
|
146
|
-
# 自动发现并注册所有命令
|
147
|
-
command_instances = CommandDiscover().discover()
|
148
|
-
commands = {}
|
149
|
-
for instance in command_instances:
|
150
|
-
command_name = instance.get_command_name()
|
151
|
-
commands[command_name] = instance
|
152
|
-
|
153
|
-
fire.Fire(commands)
|
154
|
-
```
|
155
|
-
|
156
132
|
# 🛠️ 内置工具
|
157
133
|
|
158
134
|
### 1. 数据库管理
|
@@ -219,9 +195,6 @@ class Settings(BaseSettings):
|
|
219
195
|
DB_USER: str = "postgres"
|
220
196
|
DB_PASSWORD: str = "password"
|
221
197
|
DB_DATABASE: str = "mydb"
|
222
|
-
|
223
|
-
# 实例化配置
|
224
|
-
configs = Settings()
|
225
198
|
```
|
226
199
|
|
227
200
|
### 环境变量支持
|
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
|