2014-10-07 44 views
0

Python函数我要救一个.ttl从javascript函数文件中的类型“人”的资源:“的方法不允许”在烧瓶

这是我的SPARQL查询:

@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 

,这是我与Ajax调用javascript函数:

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); 
    } 
    }); 
    } 

我不知道为什么它不”工作,任何想法?

+0

我不希望你最终得到你想要的查询。尝试打印出查询并使用sparql.org的查询验证器进行检查。 – 2014-10-07 15:22:15

+0

“它不起作用”是不够的信息。你试图在哪里运行?你会得到什么错误信息?你有没有回溯? – 2014-10-07 15:22:48

回答

1

您的端点只接受POST请求:@app.route('/registraAnnotatore/<author>+<mail>', methods=['POST'])和你的客户,你正在做一个GET请求method: 'GET',

这就是为什么你得到405不允许此端点(/registraAnnotatore/<author>+<mail>)。