diff --git a/pyShelf.py b/pyShelf.py index 0e2567e..b8b3caf 100755 --- a/pyShelf.py +++ b/pyShelf.py @@ -3,52 +3,92 @@ import asyncio import sys from pathlib import Path +from threading import Thread -# import websockets +import uvicorn +from fastapi import FastAPI +from fastapi.responses import HTMLResponse +from fastapi.routing import APIRoute from src.backend.lib.config import Config from src.backend.pyShelf_MakeCollections import MakeCollections from src.backend.pyShelf_ScanLibrary import execute_scan +# import websockets + + root = Path.cwd() config = Config(root) PRG_PATH = Path.cwd().__str__() sys.path.insert(0, PRG_PATH) - -tx = None +app = FastAPI() -async def RunImport(): +def RunImport(): """Begin live import of books.""" + config.logger.info("Begining book import.") execute_scan(PRG_PATH, config=config) + config.logger.info("Finished book import.") MakeCollections(PRG_PATH, config=config) return "Import Complete" -async def socketio(websocket, path): - """Web Socket Controller.""" - async for message in websocket: - config.logger.info("Message Processing") - if message == "ping": - config.logger.info("<< Ping") - tx = pong() - elif message == "importBooks": - config.logger.info("Starting Import") - tx = "Starting Import . . ." - await websocket.send(tx) - await RunImport() - tx = "complete" - await websocket.send(tx) +def use_route_names_as_operation_ids(app: FastAPI) -> None: + for route in app.routes: + if isinstance(route, APIRoute): + route.operation_id = route.name -def pong(): - """Respond to incoming pings.""" - config.logger.info(">> Pong") - return "pong" +@app.get("/", response_class=HTMLResponse) +async def index(): + return """ + +
+