-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.py
More file actions
42 lines (34 loc) · 903 Bytes
/
response.py
File metadata and controls
42 lines (34 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#coding=utf-8
import json
from flask import jsonify
status = {
"code": '',
"message": 0
}
def set_status(code = 0, msg = ''):
status["code"] = code
status["message"] = msg
# print(status["code"])
def check_json_format(raw_msg):
if isinstance(raw_msg, str): # 首先判断变量是否为字符串
try:
json.loads(raw_msg, encoding='utf-8')
except ValueError:
return False
return True
else:
return False
def back_res(data = {}):
for item in data['rows']:
for val in item:
tmp = item[val]
if(check_json_format(tmp)):
print(11111)
item[val] = [{"label": 1}]
return data
# print(status["code"], 1111)
# return {
# "ResponseCode": status["code"],
# "Data": data,
# "ResponseMessage": status["message"]
# }