Python/Flask-服务器正在将POST请求作为GET请求接收 [英] Python / Flask -- server is receiving POST requests as GET requests

查看:43
本文介绍了Python/Flask-服务器正在将POST请求作为GET请求接收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在烧瓶文件中创建了一个如下所示的端点

I created an endpoint in the flask file that looks like this

@app.route("/update", methods=['POST', 'GET'])
def update_func():
    results = {
        "method": request.method
    }
    return json.dumps(results)

我尝试使用Postman和python调用此函数,两者都说Flask将其作为get请求进行处理.

I tried calling this function using both Postman and python, both are saying Flask is processing it as a get request.

import requests
r = requests.post("http://site.fakeurl.org/update", json={})
print r.json()

在此过程中是否需要更改配置文件作为POST请求?

Is there a config file I need to change for this process as a POST request?

其他任何人都在发生这种情况吗?

Is this happening to anyone else?

推荐答案

您尝试使用 http://www.site.faekurl.org/update ?

某些服务器将http://重定向到 http://www.-- ,因此,POST请求+它的数据在此过程中丢失.

Some servers redirect http:// to http://www.-- and as a result, the POST request + it's data gets lost in the process.

这篇关于Python/Flask-服务器正在将POST请求作为GET请求接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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