【发布时间】:2016-03-12 03:39:28
【问题描述】:
我正在使用 Python Flask 框架来构建我的网站。我尝试使用 ajax 调用来获取服务器响应并导致 500 内部错误。
app.py
from flask import Flask, render_template,request
@app.route(''+'/api/suggest/')
def api():
pass
index.js
new Ajax.Request('api/suggest/',{
method: 'get',
onSuccess: function(response) {
alert(response);
}
});
http://localhost:5000/api/suggest/ 返回 500 内部服务器错误
加载资源失败:服务器响应状态为 500 (内部服务器错误)
【问题讨论】:
-
您是否运行了您的烧瓶应用程序以确保其正常工作?据我所知,如果那是你的代码,它看起来不太好。
-
@idjaw 是的 localhost:5000 对我来说很好
-
@app.route(""+/api/suggest")但这是错误的。您是否显示了确切的代码? -
@idjaw 我在帖子中的错误。应该是@app.route(''+'/api/suggest'),还是一样的错误。
-
''+'/api/suggest/'与'/api/suggest/'相同。