This commit is contained in:
lichen
2022-04-12 16:52:54 +08:00
parent 25abdaf64f
commit cbcdb2bf8a

View File

@ -27,12 +27,12 @@ import logging
app = Flask(__name__) app = Flask(__name__)
# 日志系统配置 # 日志系统配置
handler = logging.FileHandler('app.log', encoding='UTF-8') #handler = logging.FileHandler('app.log', encoding='UTF-8')
handler.setLevel(logging.DEBUG) #handler.setLevel(logging.DEBUG)
logging_format = logging.Formatter( #logging_format = logging.Formatter(
'%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s') # '%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')
handler.setFormatter(logging_format) #handler.setFormatter(logging_format)
app.logger.addHandler(handler) #app.logger.addHandler(handler)
''' '''
load model load model
''' '''
@ -70,7 +70,7 @@ def loadModel():
return all_model return all_model
def CheckRange(code): def CheckRange(code):
with open('goodsCategory.json', 'r', encoding='utf-8') as jsonPath: with open('../module/ieemoo-ai-predict/data/goodsCategory.json', 'r', encoding='utf-8') as jsonPath:
loadDict = json.load(jsonPath) loadDict = json.load(jsonPath)
for key in loadDict: for key in loadDict:
if code in loadDict[key]: if code in loadDict[key]:
@ -178,7 +178,7 @@ def predict():
if request.method == 'POST': if request.method == 'POST':
try: try:
data = request.get_data() data = request.get_data()
print(type(data)) print(data)
data_str = data.decode("utf-8") data_str = data.decode("utf-8")
json_data = json.loads(data_str) json_data = json.loads(data_str)
pic = json_data.get("file") pic = json_data.get("file")