diff --git a/src/server/fastapi_app.py b/src/server/fastapi_app.py index b10d2d9..e33ce66 100644 --- a/src/server/fastapi_app.py +++ b/src/server/fastapi_app.py @@ -26,7 +26,7 @@ sys.path.insert(0, os.path.abspath(parent_dir)) from fastapi import FastAPI, HTTPException, Depends, Security, status, Request from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials from fastapi.middleware.cors import CORSMiddleware -from fastapi.responses import JSONResponse +from fastapi.responses import JSONResponse, HTMLResponse from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates from pydantic import BaseModel, Field @@ -375,6 +375,27 @@ async def root(): """Root endpoint redirect to docs.""" return {"message": "AniWorld API", "documentation": "/docs", "health": "/health"} +# Web interface routes +@app.get("/app", response_class=HTMLResponse) +async def web_app(request: Request): + """Serve the main web application.""" + return templates.TemplateResponse("base/index.html", {"request": request}) + +@app.get("/login", response_class=HTMLResponse) +async def login_page(request: Request): + """Serve the login page.""" + return templates.TemplateResponse("base/login.html", {"request": request}) + +@app.get("/setup", response_class=HTMLResponse) +async def setup_page(request: Request): + """Serve the setup page.""" + return templates.TemplateResponse("base/setup.html", {"request": request}) + +@app.get("/queue", response_class=HTMLResponse) +async def queue_page(request: Request): + """Serve the queue page.""" + return templates.TemplateResponse("base/queue.html", {"request": request}) + # Anime endpoints (protected) @app.get("/api/anime/search", response_model=List[AnimeResponse], tags=["Anime"]) async def search_anime( diff --git a/src/server/web/static/js/app.js b/src/server/web/static/js/app.js index ca3574d..bb79813 100644 --- a/src/server/web/static/js/app.js +++ b/src/server/web/static/js/app.js @@ -492,7 +492,7 @@ class AniWorldApp { try { this.showLoading(); - const response = await fetch('/api/series'); + const response = await fetch('/api/v1/anime'); if (response.status === 401) { window.location.href = '/login'; @@ -720,7 +720,7 @@ class AniWorldApp { try { this.showLoading(); - const response = await this.makeAuthenticatedRequest('/api/search', { + const response = await this.makeAuthenticatedRequest('/api/v1/anime/search', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -831,7 +831,7 @@ class AniWorldApp { async rescanSeries() { try { - const response = await this.makeAuthenticatedRequest('/api/rescan', { + const response = await this.makeAuthenticatedRequest('/api/v1/anime/rescan', { method: 'POST' }); diff --git a/src/server/web/templates/base/index.html b/src/server/web/templates/base/index.html index 4f37821..0f7a007 100644 --- a/src/server/web/templates/base/index.html +++ b/src/server/web/templates/base/index.html @@ -5,11 +5,11 @@ AniWorld Manager - + - + @@ -456,25 +456,25 @@ - + - - - - - - + + + + + + - - - - - - + + + + + + - + \ No newline at end of file diff --git a/src/server/web/templates/base/login.html b/src/server/web/templates/base/login.html index 183ce37..ffda1c9 100644 --- a/src/server/web/templates/base/login.html +++ b/src/server/web/templates/base/login.html @@ -4,7 +4,7 @@ AniWorld Manager - Login - +