我正在使用python中的Flasgger和Flask为我的机器学习模型创建API。
运行API文件后,出现以下错误,提示“无法加载API文档。 提取错误 内部服务器错误/ apispex_1.json
下面是我的代码:
import pickle
from flask import Flask, abort, jsonify, request
import numpy as np
import pandas as pd
from flasgger import Swagger
with open('./im.pkl', 'rb') as model_file:
model = pickle.load(model_file)
app = Flask(__name__)
swagger = Swagger(app)
@app.route('/predict')
def predict1():
"""Example
---
parameters:
-name: Days
in: query
type= number
required: true
--
--
--
"""
Days = request.args.json('Days')
prediction = model.predict(np.array([[Days]]))
return str(prediction)
if __name__ == '__main__':
app.run(port=5000, debug=True)
答案 0 :(得分:0)
您在文档字符串描述中出现错误:
function ntsConvert(value) {
let input = String(value).split('');
let mapData = {
"0": "Zero",
"1": "One",
"2": "Two",
"3": "Three",
"4": "Four",
"5": "Five",
"6": "Six",
"7": "Seven",
"8": "Eight",
"9": "Nine"
};
let output = '';
var tempArray = []
for (let i = 0; i < input.length; i++) {
tempArray.push(mapData[input[i]])
}
output = tempArray.join(' ');
return output;
}
console.log(ntsConvert(12345)) // 'One Two Three Four Five'