Python烧瓶服务器问题

时间:2017-09-30 02:52:37

标签: python flask server

你能否帮我解决Python-Flask服务器的误解。我有一个带烧瓶的项目,它完全适用于本地服务器127.0.0.1,但是当我将它移动到Web服务器(蓝色主机)时,我的一些脚本给了我这些错误:

这里我有jQuery,Ajax响应显示没有重新加载页面的表:

<button class="myButton" id = "Lbutton">Load</button>

<script>

$("#Lbutton").click(function(){

  $.ajax({
          url: "/table,
          type: "get",
          data: {jsdata: $( "#select option:selected" ).text()},
          success: function(response) {
            $("#place_for_suggestions").html(response);

          },
          error: function(xhr) {
            // handle error
          }
        });

});

</script>

url:&#34; / table,是Flask功能的链接:

@FlaskApp2.route('/table')
def table():

    modid = request.args.get('jsdata')
    return render_template('table.html')

但最后服务器给了我错误:

  

档案不存在:/ home1 / user / public_html / 表格

为什么直接链接操作,服务器理解为文件的链接?

所以,对Python-Flask的每一个动作

<form action="/sendemail" method="post">

服务器理解为链接并给出错误消息!

我做错了什么?

2 个答案:

答案 0 :(得分:2)

解决了,我需要把完整的路径放在行动中并且路由()decorator @ app.route“/.../ templates / table.html”

答案 1 :(得分:0)

您很可能需要将POST方法添加到route定义中。

@FlaskApp2.route('/table')

变为:

@FlaskApp2.route('/table', methods=['GET', 'POST'])

查看此处的文档: http://flask.pocoo.org/docs/0.12/quickstart/#http-methods

其中有一个端点示例,它接受GET和POST HTTP方法。

另请查看相关问题:Flask example with POST