4

用Flask+python Base64构建计算机视觉Web API

 3 years ago
source link: https://panchuang.net/2021/07/29/%e7%94%a8flaskpython-base64%e6%9e%84%e5%bb%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e8%a7%86%e8%a7%89web-api/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在本文中,我将向您展示如何构建一个简单的计算机视觉Web API服务,侦听通过https post发送的图像。网络已经为智能计算做好了准备,不再仅仅是页面和数据!ğŸ�·

终端用户和隐私问题

如果您想要开发一个计算机视觉WebAPI,您很快就会深入到终端用户和隐私问题;很明显,任何这样的API都必须读取用户-™的图像,其中-欧洲˜用户-™可以(也将是)外部应用程序。因此,您不想保存原始图像或转换后的图像,而只想作为一项服务来保存。(™不会保存原始图像,也不会保存转换后的图像)。

您可以选择流而不是Web套接字,但我将使用Base64。它是一种编码系统,允许将二进制数据转换为ASCII文本字符串。

构建API

我们将使用:

?·作为Web服务器的Flask(带flask_CORS)

¨·作为API路由器的蓝图

»·Base64 Python Libray用于与浏览器交换图像

»·一个简单的标准HTML页面作为客户端

让-Euroflask s从server.py(启动™服务器的位置)开始。

烧瓶_CORS

Flask CORS允许我们的服务接收来自托管在其他域上的外部应用程序的请求。

我们使用Blueprint来为我们的API提供不同的路由,并使我们的Flask服务器模块化。

immagi.py(服务)

查看Imports语句,我们从api.immagi导入immagi

解码/编码base64图像

现在,我们在immagi.py中为API创建一条路由

我们需要的图书馆。

从_B64逐步开始()

原创文章,作者:fendouai,如若转载,请注明出处:https://panchuang.net/2021/07/29/%e7%94%a8flaskpython-base64%e6%9e%84%e5%bb%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e8%a7%86%e8%a7%89web-api/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK