简体   繁体   English

Flask内部可以发布python吗?

[英]Can Flask post internally in python?

Is it possible to make an internal post in flask? 可以在烧瓶中制作内部柱子吗? I'm trying to figure out how to post to an external site inside of python. 我正在试图找出如何发布到python内部的外部网站。 Lets say I have a simple method like: 可以说我有一个简单的方法,如:

    @app.route("/<test_value>", methods=["GET","POST"])  
        def test_post(test_value):
            ?post?(test_value, url)
            return redirect("/")

Is there method I could use to make that post or would I be best off using javascript? 我可以使用哪种方法来制作该帖子,还是我最好使用javascript?

The requests library is the most popular one, here is a sample code on how to send a post with some data. requests库是最受欢迎的库,下面是如何使用某些数据发送帖子的示例代码。

>>> payload = {'key1': 'value1', 'key2': 'value2'}
>>> r = requests.post("http://httpbin.org/post", data=payload)
>>> print(r.text)
{
  ...
  "form": {
    "key2": "value2",
    "key1": "value1"
  },
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM