"不准法"在Python功能瓶 [英] "method not allowed" in a python function for flask

查看:158
本文介绍了"不准法"在Python功能瓶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要保存在.ttl文件中的类型从JavaScript函数'人'的资源:

I want to save on a .ttl file a type 'person' resource from a javascript function:

这是我的SPARQL查询:

this is my sparql query:

@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函数:

and this is my javascript function with the ajax call:

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

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

I don't know why it doesnt' work, any ideas?

推荐答案

您端点只接受POST请求: @ app.route('/ registraAnnotatore /&LT;笔者&GT; +&LT;邮箱&GT;',方法= ['POST'])和你的客户,你正在做一个GET请求方法:GET,

Your endpoint only accepts POST request: @app.route('/registraAnnotatore/<author>+<mail>', methods=['POST']) and in your client you are doing a GET request method: 'GET',

这就是为什么你得到405不允许的方法该端点(/ registraAnnotatore /&LT <$ C C $>;作者&GT; +&LT;邮箱&GT; )。

That's why you're getting 405 METHOD NOT ALLOWED for this endpoint ( /registraAnnotatore/<author>+<mail>).

这篇关于&QUOT;不准法&QUOT;在Python功能瓶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆