python - 如何从 url 读取 tiff 文件
问题描述
我在下面发布了网络服务。打开时的 url 应该返回一个tiff
文件。当我运行此代码时,我收到以下错误消息
`(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
During handling of the above exception, another exception occurred:`
请让我知道如何接收和读取从 url 返回的 tiff 文件
代码:
@app.route("/getTIFFForURL/<string:polygonCoordinates>", methods=['GET'] )
def getTIFFForURL(polygonCoordin/ates):
url = config['EndPoint']['https'] + config['SYNOPSEndPoint']['rasterInPolygonEndPoint'] + config['SYNOPSEndPoint']['polygonToken'] + config['SYNOPSEndPoint']['polygonDelimiterOpen'] + polygonCoordinates + config['SYNOPSEndPoint']['polygonDelimiterClose'] + config['SYNOPSEndPoint']['rasterInPolygonResolutionToken']
url = url.replace(" ","%20")
url = url.replace("&","%26")
backendResponseAsTIFF = readResponseAsTIFFForURL(url)
return json.dumps(backendResponseAsTIFF)
def readResponseAsTIFFForURL(baseURL):
# TODO: remove before production:
resp = requests.get(baseURL)
tiffContents = tiff.imread(io.BytesIO(resp.content))
logger.debug(tiffContents)
return "OK"
解决方案
推荐阅读
- security - 英特尔 SGX 与沙盒有何不同?
- scala - 在运行时在 spark-scala shell 中获取 spark conf 值
- android - Android Kotlin recycler view in the fragment is not loaded with the right data when set up with TabLayout/ ViewPager sharing same fragment class
- ruby-on-rails - 我应该在哪里放置逻辑在 Ruby on Rails 项目中
- multidimensional-array - Convert 2D array to list of lists
- docker - Docker Desktop for mac OS 中的暴露和映射端口有时会在主机上返回空回复
- javascript - 如何使用 javascript 函数在 cypress 中关闭打开的打印窗口
- c# - NT AUTHORITY\Local 服务未列在目录的访问控制列表中
- cmake - 为静态库用户提供源文件夹外的包含目录
- c# - 有没有办法找到未等待的任务?