# xy_request_handler_api **Repository Path**: xy-opensource/xy_request_handler_api ## Basic Information - **Project Name**: xy_request_handler_api - **Description**: tornado请求基类封装Api - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-12 - **Last Updated**: 2024-11-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xy_request_handler_api | [简体中文](./README.md) | [繁體中文](readme/README.zh-hant.md) | [English](readme/README.en.md) | | ----------- | -------------|---------------------------------------| ## 说明 基于xy_request_handler_base的api请求基类,封装了常用功能,方便快速开发. ## 源码仓库 | [Github](https://github.com/xy-web-service/xy_request_handler_api.git) | [Gitee](https://gitee.com/xy-opensource/xy_request_handler_api.git) | [GitCode](https://gitcode.com/xy-opensource/xy_request_handler_api.git) | | ----------- | -------------|---------------------------------------| ## 安装 ```bash # bash pip install xy_request_handler_api ``` ## 使用 > 详情请查看 [Demoes.py](./samples/xy_web_server_demo/source/Runner/RequestHandlerDemo/Demoes.py) ```python # Demoes.py from xy_request_handler_api.Api import Api class Demo(Api): def check_xsrf_cookie(self) -> None: return None def check_origin(self, _): return False def post(self): json_arguments = self.json_arguments self.success() self.data = { "resp_data_json": json_arguments, } self.xy_response() ``` ##### 运行 [样例工程](./samples/xy_web_server_demo) > 样例工程具体使用方式请移步 xy_web_server.git 下列仓库 | [Github](https://github.com/xy-web-service/xy_web_server.git) | [Gitee](https://gitee.com/xy-opensource/xy_web_server.git) | [GitCode](https://gitcode.com/xy-opensource/xy_web_server.git) | | ----------- | -------------|---------------------------------------| ```bash # bash # 当前目录为xy_request_handler_api的git本地仓库所在目录 # 切换到工程目录 cd ./samples/xy_web_server_demo # 启动样例工程的Tornado服务 xy_web_server -w tornado start # 默认启动的Tornado服务url地址是: http://127.0.0.1:8400 # 浏览器打开访问 http://127.0.0.1:8400/demo 进行验证 ``` ##### 2. 检验接口请求 ```python # Python解释器 # 以下是示例代码,需要在您的应用中实现 # 用来进行测试接口请求 # Python解释器运行以下代码 import requests post_json_data = {"test":"post json data text"} url = "http://127.0.0.1:8400/demo" resp = requests.post(url, json=post_json_data) resp_json = resp.json() {'code': 0, 'message': '请求成功', 'data': {'resp_data_json': {'test': 'post json data text'}}} ``` ## 许可证 xy_request_handler_api 根据 <木兰宽松许可证, 第2版> 获得许可。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。 ## 捐赠 如果小伙伴们觉得这些工具还不错的话,能否请咱喝一杯咖啡呢? ![Pay-Total](./readme/Pay-Total.png) ## 联系方式 ``` 微信: yuyangiit 邮箱: yuyangit.0515@qq.com ```