从烧瓶路径执行post请求到远程服务

问题描述 投票:0回答:2

我遇到了一些问题,需要从我的一个@ app.route中创建并执行一个帖子请求。这个想法是验证和处理服务器从Web表单接收的数据,然后使用此数据作为post参数调用远程服务,最后重定向到此远程服务指示的新页面。这是一个简化的骨架:

import requests

@app.route('/test', methods=['POST'])

    url = 'http://exemple.com'
    headers = {'Content-type': 'text/html; charset=UTF-8'}
    response = requests.post(url, data=data, headers=headers)

    return x

有关如何使用post请求将用户重定向到远程服务的任何提示(用户将再次被远程服务重定向到另一个页面)?

先感谢您。

python flask python-requests
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.