我有一个用python运行的Flask应用程序。有一个客户端正在从磁盘提供映像服务。我想一个服务器,以达到一个终点,并检索图像
在客户方面:
@app.route('/api/get_image')
def get(self, id):
# Map id to filename.
return send_file(filename)
当我从浏览器调用客户机的端点时,这种方法就起作用了
在服务器端,我有一个类似的函数,应该调用上面的端点
@app.route('/api/get_image')
def get(self, id):
return requests.get(client_url + '/api/get_image')
当我调用服务器端点时,我得到:
TypeError: <Response [200]> is not JSON serializable
但即使我尝试使用.json(),它也不起作用。如何返回图像有效负载
不要直接从
requests.get()
返回对象,而是从中检索.raw
或.content
对象相关问题 更多 >
编程相关推荐