ajax GET可以在localhost上工作,但不能在onlin上工作

2024-05-29 04:56:39 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在localhost上运行应用程序时,它可以正常工作,但是当我在线运行时,会得到“404page not found”。同样的代码是在线和本地的。你知道吗

这里有ajax代码:

var FormAll = $("#formPdf");
$.ajax({
    type: "GET",
    dataType: "json",
    contentType: "application/json",
    url: "/Objetivo/SendPdf",
    data: FormAll.serialize(),
    success: function (resultado) {
        //do something
    },
    error: function (jqXHR, exception) {
        alert(jqXHR.status);
    }
});

下面是Python代码:

@app.route('/Objetivo/SendPdf',methods=['GET'])
def sendPdf():
    try:
       ##Do Something
    except Exception as e:
       print(e)

Tags: 代码json应用程序localhostgetvarnotajax
1条回答
网友
1楼 · 发布于 2024-05-29 04:56:39

从烧瓶Quickstart

Externally Visible Server If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.

If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding host=0.0.0.0 to the command line:

flask run host=0.0.0.0 This tells your operating system to listen on all public IPs.

相关问题 更多 >

    热门问题