import
flask import json import pymysql import tools #mock接口开发 #1.模拟接口的意思 #2.给别人提供数据 #3.flask是一个web开发框架 server=flask.Flask(__name__) # @server.route('/api/login',methods=['post','get']) # def login(): # username=flask.request.values.get('username') # password = flask.request.values.get('password') # d={'error_code':1,'msg':'登陆成功','username':username,'password':password} # return json.dump(d,ensure_ascii=False) @server.route('api/get_bill') def get_bill(): table_list=['app_myuser','czm'] table_name=flask.request.values.get('table_name') limit=flask.request.values.get('limit',50) if table_name and table_name in table_list: sql='select username from %s limit %s'(table_name,limit) result=tools.op_mysql(sql) else: data={'error_code':-1,'msg':'该表没有权限查询'} server.run(host='0.0.0.0',port=8000,debug=True)

mock接口开发需要使用flask模块,安装flask模块 pip install flask

01-09 14:28