【问题标题】:Sending an HTTP request in python with an avro/json payload?在 python 中使用 avro/json 有效负载发送 HTTP 请求?
【发布时间】:2012-07-24 04:18:40
【问题描述】:

我正在尝试找出在 http 请求中发送 avro 对象的最佳方式。我正在考虑通过python执行此操作。我对如何实现这一点有点困惑。我会创建一个数据属性等于 avro 文件所在位置的 POST 请求吗?有没有办法即时创建一大堆 avro 对象,而不是将它们存储在物理位置,而是将它们流式传输到 POST 请求中? 我不确定如何通过网络将字节数组发送到服务器。深入了解这个过程的基本原理会很棒。

谢谢

【问题讨论】:

    标签: python http httprequest avro


    【解决方案1】:

    您可能会发现 python 请求很有用。

    http://www.python-requests.org/en/latest/user/quickstart/#

    $pip install requests
    
    >>> import requests
    >>> url = 'http://httpbin.org/post'
    >>> files = {'file': open('report.xls', 'rb')}
    
    >>> r = requests.post(url, files=files)
    

    【讨论】:

      猜你喜欢
      • 2016-12-15
      • 2014-05-10
      • 1970-01-01
      • 2020-04-30
      • 2013-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多