<tfoot id='lsNp9'></tfoot>

  • <small id='lsNp9'></small><noframes id='lsNp9'>

    <legend id='lsNp9'><style id='lsNp9'><dir id='lsNp9'><q id='lsNp9'></q></dir></style></legend>

        <i id='lsNp9'><tr id='lsNp9'><dt id='lsNp9'><q id='lsNp9'><span id='lsNp9'><b id='lsNp9'><form id='lsNp9'><ins id='lsNp9'></ins><ul id='lsNp9'></ul><sub id='lsNp9'></sub></form><legend id='lsNp9'></legend><bdo id='lsNp9'><pre id='lsNp9'><center id='lsNp9'></center></pre></bdo></b><th id='lsNp9'></th></span></q></dt></tr></i><div id='lsNp9'><tfoot id='lsNp9'></tfoot><dl id='lsNp9'><fieldset id='lsNp9'></fieldset></dl></div>

        • <bdo id='lsNp9'></bdo><ul id='lsNp9'></ul>
      1. Postman、Python 以及将图像和元数据传递给 Web 服务

        Postman, Python and passing images and metadata to a web service(Postman、Python 以及将图像和元数据传递给 Web 服务)

          <tbody id='QRawO'></tbody>

            <bdo id='QRawO'></bdo><ul id='QRawO'></ul>

              • <i id='QRawO'><tr id='QRawO'><dt id='QRawO'><q id='QRawO'><span id='QRawO'><b id='QRawO'><form id='QRawO'><ins id='QRawO'></ins><ul id='QRawO'></ul><sub id='QRawO'></sub></form><legend id='QRawO'></legend><bdo id='QRawO'><pre id='QRawO'><center id='QRawO'></center></pre></bdo></b><th id='QRawO'></th></span></q></dt></tr></i><div id='QRawO'><tfoot id='QRawO'></tfoot><dl id='QRawO'><fieldset id='QRawO'></fieldset></dl></div>
                <tfoot id='QRawO'></tfoot>

                1. <legend id='QRawO'><style id='QRawO'><dir id='QRawO'><q id='QRawO'></q></dir></style></legend>

                  <small id='QRawO'></small><noframes id='QRawO'>

                  本文介绍了Postman、Python 以及将图像和元数据传递给 Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是一个由两部分组成的问题:我看过讨论的个别部分,但似乎无法将推荐的建议一起工作.我想创建一个 Web 服务来存储从调用者传递的图像及其元数据,并从 Postman 运行测试调用以确保它正常工作.因此,要通过 Postman 将图像 (Drew16.jpg) 传递给 Web 服务,看来我需要这样的东西:

                  this is a two-part question: I have seen individual pieces discussed, but can't seem to get the recommended suggestions to work together. I want to create a web service to store images and their metadata passed from a caller and run a test call from Postman to make sure it is working. So to pass an image (Drew16.jpg) to the web service via Postman, it appears I need something like this:

                  对于网络服务,我有一些 python/flask 代码来读取请求(我尝试过的许多变体之一):

                  For the web service, I have some python/flask code to read the request (one of many variations I have tried):

                  from flask import Flask, jsonify, request, render_template
                  from flask_restful import Resource, Api, reqparse
                  
                  ...
                  
                  def post(self, name):
                      request_data = request.get_json()
                      userId = request_data['UserId']
                      type = request_data['ImageType']
                      image = request.files['Image']
                  

                  数据部分和直接 JSON 没有问题,但添加图像却是个麻烦.我的邮递员配置哪里出错了?从帖子中读取元数据和文件的实际 Python 命令集是什么?TIA

                  Had no problem with the data portion and straight JSON but adding the image has been a bugger. Where am I going wrong on my Postman config? What is the actual set of Python commands for reading the metadata and the file from the post? TIA

                  推荐答案

                  请原谅几乎是博文.我发布这个是因为虽然你可以在不同的地方找到部分答案,但我还没有在任何地方看到完整的帖子,这可以节省我大量的时间.问题是你需要故事的双方来验证.

                  Pardon the almost blog post. I am posting this because while you can find partial answers in various places, I haven't run across a complete post anywhere, which would have saved me a ton of time. The problem is you need both sides to the story in order to verify either.

                  所以我想使用 Postman 向 Python/Flask Web 服务发送请求.它必须有图像和一些元数据.

                  So I want to send a request using Postman to a Python/Flask web service. It has to have an image along with some metadata.

                  这里是 Postman 的设置(URL、标题):

                  Here are the settings for Postman (URL, Headers):

                  和身体:

                  现在转到网络服务.这是一个简单的服务,它将接受请求、打印元数据并保存文件:

                  Now on to the web service. Here is a bare bones service which will take the request, print the metadata and save the file:

                  from flask import Flask, request
                  
                  app = Flask(__name__)        
                  
                  # POST - just get the image and metadata
                  @app.route('/RequestImageWithMetadata', methods=['POST'])
                  def post():
                      request_data = request.form['some_text']
                      print(request_data)
                      imagefile = request.files.get('imagefile', '')
                      imagefile.save('D:/temp/test_image.jpg')
                      return "OK", 200
                  
                  app.run(port=5000)
                  

                  享受吧!

                  这篇关于Postman、Python 以及将图像和元数据传递给 Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  <i id='8hkQa'><tr id='8hkQa'><dt id='8hkQa'><q id='8hkQa'><span id='8hkQa'><b id='8hkQa'><form id='8hkQa'><ins id='8hkQa'></ins><ul id='8hkQa'></ul><sub id='8hkQa'></sub></form><legend id='8hkQa'></legend><bdo id='8hkQa'><pre id='8hkQa'><center id='8hkQa'></center></pre></bdo></b><th id='8hkQa'></th></span></q></dt></tr></i><div id='8hkQa'><tfoot id='8hkQa'></tfoot><dl id='8hkQa'><fieldset id='8hkQa'></fieldset></dl></div>
                2. <tfoot id='8hkQa'></tfoot>

                  <small id='8hkQa'></small><noframes id='8hkQa'>

                    <tbody id='8hkQa'></tbody>
                  1. <legend id='8hkQa'><style id='8hkQa'><dir id='8hkQa'><q id='8hkQa'></q></dir></style></legend>

                            <bdo id='8hkQa'></bdo><ul id='8hkQa'></ul>