add video streaming endpoints

adjust config for bypassing nginx
add communication to ergo
add cachebusting + fixing icons
This commit is contained in:
CEF Server 2024-07-13 00:31:43 +00:00
parent 15e1018476
commit 6a69c5a34d
6 changed files with 160 additions and 10 deletions

View file

@ -1,8 +1,9 @@
import asyncio
import hashlib
import re
import config
from minio import Minio
from redis import Redis
from fastapi import UploadFile
@ -18,7 +19,51 @@ async def SHA256(f: UploadFile) -> str:
return sha.hexdigest()
minioClient = Minio(
config.MINIO_ADDR,
config.MINIO_INTERNAL_ADDR,
secure=False, # you will probably not have SSL
access_key=config.MINIO_ACCESS_KEY,
secret_key=config.MINIO_SECRET_KEY,
)
redis = Redis(host='localhost', port=6379, db=0, protocol=3)
class ErgoClient:
def __init__(self):
self.reader = None
self.writer = None
asyncio.get_running_loop().create_task(self.init())
@staticmethod
def retry(f):
async def wrapper(self, *args, **kwargs):
i = 30
while i:
try:
return await f(self, *args, **kwargs)
except RuntimeError:
self.init()
i -= 1
print("Couldn't connect")
return wrapper
@retry
async def init(self):
self.reader, self.writer = await asyncio.open_connection(config.ERGO_ADDR, config.ERGO_PORT)
@retry
async def write(self, msg):
self.writer.write(msg+b"\n")
await self.writer.drain()
async def broadcastAs(self, user, *message):
await self.write(f"BROADCASTAS {user} {' '.join(message)}".encode("utf8"))
async def broadcastTo(self, user, *message):
await self.write(f"BROADCASTTO {user} {' '.join(message)}".encode("utf8"))
ergo = ErgoClient()