采用
FastAPI是一个现代、快速(高性能)的Python 3.8+ web框架,用于构建API。
FastAPI的主要特点:
- Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.
- Fast to code: Increase the speed to develop features by about 200% to 300%. *
- Fewer bugs: Reduce about 40% of human (developer) induced errors. *
- Intuitive: Great editor support. Completion everywhere. Less time debugging.
- Easy: Designed to be easy to use and learn. Less time reading docs.
- Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
- Robust: Get production-ready code. With automatic interactive documentation.
- Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
在一些Python微服务项目中,个人都会选择FastAPI,它的性能和易用性都非常好,推荐使用。
FastAPI同时提供了一个FastAPI CLI,key很方便地管理你的项目,
建议使用rye install fastapi-cli安装。
FastAPI & Friends
- Flask: https://flask.palletsprojects.com/
- Django REST Framework: https://www.django-rest-framework.org/
- fastapi-problem: Problem details for FASTApi - https://github.com/NRWLDev/fastapi-problem
References
- FastAPI: https://fastapi.tiangolo.com/
- Zalando RESTful API and Event Guidelines: https://opensource.zalando.com/restful-api-guidelines/
- Fast(er)API: Optimizing Processing Time: https://fabridamicelli.github.io/posts/2023-07-13-optimize-fastapi.html