Metadata-Version: 2.5
Name: pythonboot-web
Version: 0.1.1
Summary: FastAPI integration and Web application startup for PythonBoot
Requires-Python: >=3.12
Requires-Dist: fastapi<1,>=0.115
Requires-Dist: pythonboot<0.2,>=0.1.1
Requires-Dist: uvicorn[standard]<1,>=0.34
Description-Content-Type: text/markdown

# pythonboot-web

PythonBoot 的独立 Web 实现包，包含 Controller、路由、异常处理、请求与响应上下文、
日期格式化、API 文档、ASGI 生命周期和 Web 启动类。

依赖 `pythonboot`、FastAPI 和 Uvicorn，用户推荐安装 `pythonboot-starter-web`。
核心接口从 `pythonboot` 导入，Web 接口从 `pythonboot_web` 导入。
原来的 `pythonboot.web` 和核心包顶层 Web 导出已移除。
YAML 的 `pythonboot.web` 配置键保持不变。

```python
from pythonboot import autowired, service
from pythonboot_web import PythonBootApplication, controller, get, pythonboot_application

@service
class GreetingService:
    def greeting(self) -> str:
        return "Hello"

@controller(prefix="/greeting")
class GreetingController:
    service: GreetingService = autowired()

    @get("")
    def greeting(self) -> str:
        return self.service.greeting()

@pythonboot_application(scan_packages=("myapp",))
class Application(PythonBootApplication):
    pass
```


完整分层应用见 [全量 Starter 示例](../../example/README.md)，包含全部 Starter、PostgreSQL／Redis 和同步／异步 HTTP 用法。
See the [complete Starter application](../../example/README.md) for all Starters and sync/async HTTP examples.


当前 FastAPI 应用自动注册为名为 `fastapiApp` 的单例 Bean，可通过 `app: FastAPI = autowired()` 注入，
或在容器启动后通过 `ContextUtil.get_bean(FastAPI)` 获取。每个应用使用独立实例；
`configure()` 执行时容器尚未启动，请直接使用传入的 `app`。禁用自动配置时此 Bean 仍会注册。


The current FastAPI application is registered as the singleton Bean `fastapiApp`.
Inject it with `app: FastAPI = autowired()` or obtain it with `ContextUtil.get_bean(FastAPI)` after container startup.
Each application has its own instance. The container has not started during `configure()`; use its `app` argument there.
The Bean is also registered when `auto_configure=False`.
