python - 应用程序中的错误:/predict [POST] 上的异常
问题描述
在 gcloud 上运行我的应用程序时,我在浏览器上遇到以下错误消息:
内部服务器错误服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出错。
在查看日志文件时,它显示:
应用程序中的错误:/predict [POST] 上的异常
我的代码如下:
@app.route('/predict', methods=['POST'])
def predict():
if request.method == 'POST':
BizUnit = request.form.get('BizUnit')
Region = request.form.get('Region')
Category = request.form.get('Category')
sel = (BizUnit, Region, Category)
dict = {'COO': 0, 'Finance': 1, 'HR': 2, 'AMER': 0, 'APAC': 1,
'EMEA': 2, 'Resources': 0, 'Facility': 1, 'Services': 2}
sel_num = ([dict[sel[0]], dict[sel[1]], dict[sel[2]]])
final_features = [np.array(sel_num)]
prediction = model.predict(final_features)
output = round(prediction[0], 2)
return render_template('index.html', prediction_text=
'Spends should be $ {}'.format(output))
如果有人能提出一些解决这个问题的建议,将不胜感激。谢谢
解决方案
推荐阅读
- javascript - 将 ASCII 值数组转换为一个字符串
- javascript - 使用 useEffect 钩子获取后 ReactJS 上下文重新渲染
- php - 如何在PHP中的字符串数组中获取某个数值?
- r - 使用 ODBC 包连接到 R 中的 SQL Server 到非默认端口
- ruby-on-rails - 如何在现有的属性轨上集成枚举
- postgresql - 如何使用 sqlmock 模拟 db.QueryRow
- javascript - Awaited Promises 创建 Array.map 返回
- angular - Ag 网格快速过滤器错误单元格行未过滤
- javascript - 通过 JSP 在脚本上获取 textarea 编辑的文本
- json - 在颤振中将请求复杂的json发布到api