Implemented bot endpoint with DB requests and other tweaks

This commit is contained in:
Logan Cusano
2025-05-24 18:12:59 -04:00
parent 15b12ecd5f
commit 107ab049ff
6 changed files with 350 additions and 35 deletions

View File

@@ -5,6 +5,8 @@ import uuid
from quart import Quart, jsonify, request
from routers.systems import systems_bp
from routers.nodes import nodes_bp, register_client, unregister_client
from routers.bot import bot_bp
from internal.db_wrappers import SystemDbController, DiscordIdDbController
# --- WebSocket Server Components ---
# Dictionary to store active clients: {client_id: websocket}
@@ -52,6 +54,10 @@ websocket_server_instance = None
# Make active_clients accessible via the app instance.
app.active_clients = active_clients
# Create and attach the DB wrappers
app.sys_db_h = SystemDbController()
app.d_id_db_h = DiscordIdDbController()
@app.before_serving
async def startup_websocket_server():
"""Starts the WebSocket server when the Quart app starts."""
@@ -79,19 +85,12 @@ async def shutdown_websocket_server():
app.register_blueprint(systems_bp, url_prefix="/systems")
app.register_blueprint(nodes_bp, url_prefix="/nodes")
app.register_blueprint(bot_bp, url_prefix="/bots")
@app.route('/')
async def index():
return "Welcome to the Radio App Server API!"
@app.route('/request_token', methods=['POST'])
async def request_token():
"""API endpoint to list currently connected client IDs."""
# TODO - Add DB logic
return jsonify({
"token": "MTE5NjAwNTM2ODYzNjExMjk3Nw.GuCMXg.24iNNofNNumq46FIj68zMe9RmQgugAgfrvelEA"
})
# --- Main Execution ---
if __name__ == "__main__":
# Quart's app.run() will start the asyncio event loop and manage it.