faster-app 0.0.12__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.
Files changed (42) hide show
  1. {faster_app-0.0.12 → faster_app-0.0.14}/PKG-INFO +1 -1
  2. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/__init__.py +1 -1
  3. faster_app-0.0.14/faster_app/commands/builtins/app.py +46 -0
  4. faster_app-0.0.12/faster_app/commands/builtins/fastapi.py → faster_app-0.0.14/faster_app/commands/builtins/server.py +16 -4
  5. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/PKG-INFO +1 -1
  6. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/SOURCES.txt +1 -1
  7. {faster_app-0.0.12 → faster_app-0.0.14}/pyproject.toml +1 -1
  8. faster_app-0.0.12/faster_app/commands/builtins/app.py +0 -29
  9. {faster_app-0.0.12 → faster_app-0.0.14}/LICENSE +0 -0
  10. {faster_app-0.0.12 → faster_app-0.0.14}/README.md +0 -0
  11. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/.env.example +0 -0
  12. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/base.py +0 -0
  13. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/commands/__init__.py +0 -0
  14. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/commands/base.py +0 -0
  15. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/commands/builtins/__init__.py +0 -0
  16. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/commands/builtins/db.py +0 -0
  17. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/commands/discover.py +0 -0
  18. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/db.py +0 -0
  19. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/main.py +0 -0
  20. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/models/__init__.py +0 -0
  21. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/models/base.py +0 -0
  22. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/models/discover.py +0 -0
  23. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/__init__.py +0 -0
  24. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/base.py +0 -0
  25. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/builtins/__init__.py +0 -0
  26. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/builtins/defaults.py +0 -0
  27. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/builtins/swagger.py +0 -0
  28. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/routes/discover.py +0 -0
  29. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/settings/__init__.py +0 -0
  30. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/settings/builtins/settings.py +0 -0
  31. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/settings/discover.py +0 -0
  32. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/statics/swagger-ui-bundle.min.js +0 -0
  33. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/statics/swagger-ui.min.css +0 -0
  34. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/templates/apps/demo/commands.py +0 -0
  35. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/templates/apps/demo/models.py +0 -0
  36. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/templates/apps/demo/routes.py +0 -0
  37. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app/templates/config/settings.py +0 -0
  38. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/dependency_links.txt +0 -0
  39. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/entry_points.txt +0 -0
  40. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/requires.txt +0 -0
  41. {faster_app-0.0.12 → faster_app-0.0.14}/faster_app.egg-info/top_level.txt +0 -0
  42. {faster_app-0.0.12 → faster_app-0.0.14}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster_app
3
- Version: 0.0.12
3
+ Version: 0.0.14
4
4
  Summary: 一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能
5
5
  Author-email: peizhenfei <peizhenfei@hotmail.com>
6
6
  Maintainer-email: peizhenfei <peizhenfei@hotmail.com>
@@ -9,7 +9,7 @@ Faster APP - 一个轻量级的 Python Web 框架
9
9
  - 数据库连接管理 (tortoise_init)
10
10
  """
11
11
 
12
- __version__ = "0.0.12"
12
+ __version__ = "0.0.14"
13
13
  __author__ = "peizhenfei"
14
14
  __email__ = "peizhenfei@hotmail.com"
15
15
 
@@ -0,0 +1,46 @@
1
+ import os
2
+ import shutil
3
+ from faster_app.commands.base import CommandBase
4
+ from rich.console import Console
5
+
6
+ console = Console()
7
+
8
+
9
+ class AppCommand(CommandBase):
10
+ """App Command"""
11
+
12
+ async def env(self):
13
+ """Create .env file"""
14
+ # 拷贝项目根路径下的 .env.example 文件到项目根路径
15
+ try:
16
+ shutil.copy(f"{self.BASE_PATH}/.env.example", ".env")
17
+ console.print("✅ .env created successfully")
18
+ except FileExistsError:
19
+ console.print("✅ .env already exists")
20
+ except Exception as e:
21
+ console.print(f"❌ .env created failed: {e}")
22
+
23
+ async def demo(self):
24
+ """create demo app"""
25
+ # 项目根路径下创建 apps 目录,如果存在则跳过
26
+ try:
27
+ if not os.path.exists("apps"):
28
+ os.makedirs("apps")
29
+ # 拷贝 templates/apps/demo 目录到 apps 目录
30
+ shutil.copytree(f"{self.BASE_PATH}/templates/apps/demo", "apps/demo")
31
+ console.print("✅ apps/demo created successfully")
32
+ except FileExistsError:
33
+ console.print("✅ apps/demo already exists")
34
+ except Exception as e:
35
+ console.print(f"❌ apps/demo created failed: {e}")
36
+
37
+ async def config(self):
38
+ """create config"""
39
+ # 拷贝 templates/config 到 . 目录
40
+ try:
41
+ shutil.copytree(f"{self.BASE_PATH}/templates/config", "./config")
42
+ console.print("✅ config created successfully")
43
+ except FileExistsError:
44
+ console.print("✅ config already exists")
45
+ except Exception as e:
46
+ console.print(f"❌ config created failed: {e}")
@@ -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",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster_app
3
- Version: 0.0.12
3
+ Version: 0.0.14
4
4
  Summary: 一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能
5
5
  Author-email: peizhenfei <peizhenfei@hotmail.com>
6
6
  Maintainer-email: peizhenfei <peizhenfei@hotmail.com>
@@ -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/fastapi.py
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "faster_app"
7
- version = "0.0.12"
7
+ version = "0.0.14"
8
8
  description = "一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,29 +0,0 @@
1
- import os
2
- import shutil
3
- from faster_app.commands.base import CommandBase
4
- from rich.console import Console
5
-
6
- console = Console()
7
-
8
-
9
- class AppCommand(CommandBase):
10
- """App Command"""
11
-
12
- async def env(self):
13
- """Create .env file"""
14
- # 拷贝项目根路径下的 .env.example 文件到项目根路径
15
- shutil.copy(f"{self.BASE_PATH}/.env.example", ".env")
16
- console.print("✅ .env created successfully")
17
-
18
- async def demo(self):
19
- """create demo app"""
20
- # 项目根路径下创建 apps 目录,如果存在则跳过
21
- if not os.path.exists("apps"):
22
- os.makedirs("apps")
23
- # 拷贝 templates/apps/demo 目录到 apps 目录
24
- shutil.copytree(f"{self.BASE_PATH}/templates/apps/demo", "apps/demo")
25
-
26
- async def config(self):
27
- """create config"""
28
- # 拷贝 templates/config 到 . 目录
29
- shutil.copytree(f"{self.BASE_PATH}/templates/config", ".")
File without changes
File without changes
File without changes