我的项目使用 socket.io 发送/接收数据。
我添加了 aiohttp 来帮助在浏览器上显示结果。
import asyncio
from aiohttp import web
sio = socketio.AsyncServer(async_mode='`aiohttp`')
app = web.Application()
sio.attach(app)
Run Code Online (Sandbox Code Playgroud)
我按照 https://us-pycon-2019-tutorial.readthedocs.io/aiohttp_file_uploading.html 上传图片,但无法上传视频。
def gen1():
# while True:
# if len(pm.list_image_display) > 1 :
image = cv2.imread("/home/duong/Pictures/Chess_Board.svg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# img = PIL.Image.new("RGB", (64, 64), color=(255,255,0))
image_pil = PIL.Image.fromarray(image)
fp = io.BytesIO()
image_pil.save(fp, format="JPEG")
content = fp.getvalue()
return content
async def send1():
print("11")
return web.Response(body=gen1(), content_type='image/jpeg')
Run Code Online (Sandbox Code Playgroud)
如何在浏览器上通过 aiohttp 显示视频?