httprest库,包括oopreadise和OpenAPI生成
restit的Python项目详细描述
pythonhttprest库,包括OOP就绪性和openapi生成
有关更全面的文档,请参见:https://restit.readthedocs.io/en/latest/
特点
- WSGI符合
- 验证(使用marshmallow)
- 查询参数验证
- 路径参数验证
- 请求正文验证
- 响应主体验证
- OpenApi文档生成
- OOP-就绪(不需要基于模块的全局实例)
- 轻松生成超链接
- 异常映射
- 响应序列化自定义
- 请求反序列化自定义
- 易于测试
简单的例子
fromrestitimportRequest,Resource,Response,RestItAppfromrestit.decoratorimportpath@path("/")classIndexResource(Resource):defget(self,request:Request)->Response:returnResponse("Hello from index.")app=RestItApp(resources=[IndexResource()])if__name__=="__main__":# start a development server on http://127.0.0.1:5000app.start_development_server()
您还可以使用生产就绪的服务器,如Gunicorn (以上模块的名称为restit\u app_测试.py):
^{pr2}$- 项目
标签: