iSanic-e
基于 Sanic 的类型化表单验证后端脚手架。
安装后可以通过 isanic init 快速生成一个完整可运行的 Sanic 项目,内置:
- 控制器自动路由注册
- Pydantic v2 表单验证
- 统一成功和错误响应
- 全局异常处理
- 示例控制器、表单模型和测试
安装
python -m pip install isanic-e
初始化项目
isanic init demo
cd demo
python -m pip install -e ".[dev]"
python -m pytest
python -m app.main
控制器示例
from app.api.schemas.login import LoginForm
from isanic import ApiController
class Login(ApiController):
async def post_submit(self, form: LoginForm) -> dict[str, str]:
return {"token": f"token-for-{form.username}"}
上面的代码会自动注册为:
POST /login/submit
业务异常
from isanic import AppError
raise AppError("用户已被禁用", code="USER_DISABLED", status_code=403)
返回:
{
"code": "USER_DISABLED",
"message": "用户已被禁用",
"data": null
}
Metadata
Release files for isanic-e 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| isanic_e-0.1.0.tar.gz | 14.3 kB | Without provenance | Details for isanic_e-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| isanic_e-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for isanic_e-0.1.0-py3-none-any.whl |
Total release size: 31.9 kB
Release files / isanic_e-0.1.0.tar.gz
| Download URL | isanic_e-0.1.0.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d860089bfc638b505312d12ea98f4c56b8859d581fc22e6c86b2876e4c6ad799
|
|
BLAKE2b-256 checksum How to use checksums |
aacf2636f42cc97a66b0efe047be0799264e6801fdbe6e8aeed5ca9a2cafaf5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / isanic_e-0.1.0-py3-none-any.whl
| Download URL | isanic_e-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
496b5f9aa34c3c0e6032ab4ab789a9cdda5e8e4f5c27d1a3cb55a991906563e5
|
|
BLAKE2b-256 checksum How to use checksums |
1d277ca5f6d768952a95847340cf9c5edc4601b32a323a224aab0d1ab8a9cd71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for isanic-e 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.