Javascript &引用;“不允许使用方法”;在用于flask的python函数中
我想在.ttl文件中保存来自javascript函数的类型“person”资源: 这是我的sparql查询:Javascript &引用;“不允许使用方法”;在用于flask的python函数中,javascript,python,ajax,sparql,semantic-web,Javascript,Python,Ajax,Sparql,Semantic Web,我想在.ttl文件中保存来自javascript函数的类型“person”资源: 这是我的sparql查询: @app.route('/registraAnnotatore/<author>+<mail>', methods=['POST']) def registraAnnotatore(author,mail): sparql = SPARQLWrapper("http://localhost:3030/data/update") mailto
@app.route('/registraAnnotatore/<author>+<mail>', methods=['POST'])
def registraAnnotatore(author,mail):
sparql = SPARQLWrapper("http://localhost:3030/data/update")
mailto = "<mailto:"+mail+">"
sparql.setQuery("""
PREFIX aop: <http://vitali.web.cs.unibo.it/AnnOtaria/person/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX schema: <http://schema.org/>
INSERT DATA
{ """+mailto+""" a foaf:Person;
foaf:name """+author+""";
schema:email """+mail+""".
}
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
results = results['results']['bindings']
results = json.dumps(results)
return results
我不知道为什么它不起作用,有什么想法吗?你的端点只接受POST请求:
@app.route('/registrannotatore/+',methods=['POST'])
并且在你的客户端你正在做一个GET请求方法:'GET',
这就是为什么此端点不允许使用405方法(
/registrannotatore/+
) 我不希望你最终得到你想要的查询。试着打印查询并用sparql.org的查询验证程序进行检查,“它不工作”是不够的信息。你想把这个放在哪里?您收到了什么错误消息?你有回溯吗?
function salvaRemoto(){
$.ajax({
method: 'GET',
url: '/verificaAnnotatore/'+fullname+'+'+email,
success: function(d) {
d = JSON.parse(d);
alert(d.length);
if(d.length>0){
}else{
//registrazione nuovo utente
$.ajax({
method: 'POST',
url: '/registraAnnotatore/'+fullname+'+'+email,
success: function() {
alert("Utente registrato !!!");
},
error: function(a,b,c) {
alert(a + ' ' + b + ' ' + c);
}
});
}
},
error: function(a,b,c) {
alert(a + ' ' + b + ' ' + c);
}
});
}