# -*- coding: utf-8 -*-
import pymysql
import os
import json
#from flask_cors import *
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
from flask import Flask, request
app = Flask(__name__)
@app.route('/index1', methods=['GET'])
def indextest():
inputData = request.args.get("inputData")
data1 = getcontent(inputData)
return data1
def getcontent(inputData):
conn = pymysql.connect(
host='*****',
port=****,
user='****',
passwd='****',
)
selectlanguage = "SELECT * FROM manager_relation.relation_name where phone={}".format(inputData)
cur = conn.cursor()
cur.execute(selectlanguage)
data = cur.fetchall()
cur.close()
print(len(data),data)
results = []
for i in range(len(data)):
result = {'id':data[i][0], '名字':data[ i][1], '职位':data[ i][2],'联系方式':data[0][3]}
results.append(result)
return json.dumps(results, ensure_ascii=False, indent=4) # 用于将字典形式的数据转化为字符串
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)