PyNest基于fastapi 类似nestjs 的python 框架

PyNest基于fastapi 类似nestjs 的python 框架

支持的特性

  • 依赖注入
  • 类型注解
  • 装饰器
  • 代码生成

参考使用

  • 安装cli
pip install pynest-api
  • 创建项目
pynest create-nest-app -n my_app_name
  • 添加模块
pynest g module -n users
  • 效果

 


代码结构

 
├── README.md
├── app.py
├── main.py
├── requirements.txt
└── src
    ├── __init__.py
    └── users
        ├── __init__.py
        ├── users_controller.py
        ├── users_model.py
        ├── users_module.py
        └── users_service.py

模块效果

 

  • 启动
 
uvicorn "app:app" --host "0.0.0.0" --port "8000" --reload
  • 效果

openapi 信息

说明

目前来看PyNest使用上还是比较简洁的,值得尝试下

参考资料

https://fastapi.tiangolo.com/
https://github.com/tiangolo/fastapi
https://github.com/PythonNest/PyNest
https://pythonnest.github.io/PyNest/

posted on 2024-04-02 08:00  荣锋亮  阅读(24)  评论(0编辑  收藏  举报

导航