stoof
This commit is contained in:
@@ -1,8 +1,21 @@
|
||||
#!/usr/bin/env python3.12
|
||||
|
||||
from fastapi import FastAPI, Request, HTTPException
|
||||
from fastapi import FastAPI, Request, HTTPException, WebSocket, WebSocketDisconnect, WebSocketException
|
||||
from pydantic import BaseModel
|
||||
from aiohttp import ClientSession, ClientTimeout
|
||||
from aces.connection_manager import ConnectionManager
|
||||
from aces.flac_reader import AudioStreamer
|
||||
|
||||
import os
|
||||
import asyncio
|
||||
import pyaudio
|
||||
import wave
|
||||
import traceback
|
||||
import pyflac.decoder as decoder
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
import json
|
||||
import time
|
||||
|
||||
class ValidXCRequest(BaseModel):
|
||||
"""
|
||||
@@ -17,6 +30,8 @@ class ValidXCRequest(BaseModel):
|
||||
cmd: str
|
||||
data: dict | None = None
|
||||
|
||||
|
||||
|
||||
class XC(FastAPI):
|
||||
"""XC (CrossComm) Endpoints"""
|
||||
def __init__(self, app: FastAPI, util, constants, glob_state): # pylint: disable=super-init-not-called
|
||||
@@ -25,14 +40,26 @@ class XC(FastAPI):
|
||||
self.constants = constants
|
||||
self.glob_state = glob_state
|
||||
|
||||
self.ws_endpoints = {
|
||||
# "aces_ws_put": self.put_ws_handler,
|
||||
}
|
||||
|
||||
self.endpoints = {
|
||||
"xc": self.xc_handler,
|
||||
#tbd
|
||||
}
|
||||
|
||||
|
||||
for endpoint, handler in self.ws_endpoints.items():
|
||||
app.add_api_websocket_route(f"/{endpoint}/", handler)
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
app.add_api_route(f"/{endpoint}/", handler, methods=["POST"])
|
||||
|
||||
|
||||
# async def put_ws_handler(self, ws: WebSocket):
|
||||
# await ws.accept()
|
||||
# await self.audio_streamer.handle_client(ws)
|
||||
|
||||
async def xc_handler(self, data: ValidXCRequest, request: Request):
|
||||
"""
|
||||
/xc/
|
||||
|
||||
Reference in New Issue
Block a user