企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
对 `app/api_1_0/controller` 下的 `passport.py` 控制器进行如下改造 ``` #!/usr/bin/env python3 # -*- encoding: utf-8 -*- from app.api_1_0 import bp from flask import request @bp.route('/register', methods=['POST']) def register(): json_date = request.get_json() return '注册接收到 \n 姓名:%s \n 手机:%s \n' % (json_date['username'],json_date['mobile']) @bp.route('/login', methods=['POST']) def login(): pass @bp.route('/logout', methods=['DELETE']) def logout(): pass ``` 测试 ``` root@airvip:~/python_app/flask-demo# curl 127.0.0.1:5000/api/v1.0/register -X POST -d '{"username":"阿尔维奇","mobile":"13108765051"}' -H 'Content-Type: application/json' 注册接收到 姓名:阿尔维奇 手机:13108765051 ``` ![request_json](https://img.kancloud.cn/0a/c7/0ac70d0aba01d813662963c2d99375ce_1205x84.png)