From 7b933b6cdb255fa6abe9402448ca80aeeb167e1f Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 12 Oct 2025 19:54:44 +0200 Subject: [PATCH] test and move of controllers --- ServerTodo.md | 227 ----------- TestsTodo.md | 180 --------- instruction.md | 100 +++++ src/config/settings.py | 30 ++ src/server/config/settings.py | 28 ++ src/server/controllers/anime_controller.py | 70 ++++ src/server/controllers/auth_controller.py | 39 ++ src/server/controllers/episode_controller.py | 19 + src/server/controllers/setup_controller.py | 19 + src/server/controllers/system_controller.py | 28 ++ src/server/controllers/v2/anime_controller.py | 45 +++ src/server/controllers/v2/auth_controller.py | 18 + .../controllers/v2/episode_controller.py | 15 + src/server/controllers/v2/setup_controller.py | 13 + .../controllers/v2/system_controller.py | 13 + src/server/fastapi_app.py | 355 ++---------------- src/server/requirements.txt | Bin 1470 -> 0 bytes src/server/tests/test_controllers.py | 34 ++ src/server/tests/test_settings.py | 24 ++ 19 files changed, 527 insertions(+), 730 deletions(-) delete mode 100644 ServerTodo.md delete mode 100644 TestsTodo.md create mode 100644 instruction.md create mode 100644 src/config/settings.py create mode 100644 src/server/config/settings.py create mode 100644 src/server/controllers/anime_controller.py create mode 100644 src/server/controllers/auth_controller.py create mode 100644 src/server/controllers/episode_controller.py create mode 100644 src/server/controllers/setup_controller.py create mode 100644 src/server/controllers/system_controller.py create mode 100644 src/server/controllers/v2/anime_controller.py create mode 100644 src/server/controllers/v2/auth_controller.py create mode 100644 src/server/controllers/v2/episode_controller.py create mode 100644 src/server/controllers/v2/setup_controller.py create mode 100644 src/server/controllers/v2/system_controller.py delete mode 100644 src/server/requirements.txt create mode 100644 src/server/tests/test_controllers.py create mode 100644 src/server/tests/test_settings.py diff --git a/ServerTodo.md b/ServerTodo.md deleted file mode 100644 index dca2ba6..0000000 --- a/ServerTodo.md +++ /dev/null @@ -1,227 +0,0 @@ -# Web Migration TODO: Flask to FastAPI - -This document contains tasks for migrating the web application from Flask to FastAPI. Each task should be marked as completed with [x] when finished. - -## ๐Ÿ“‹ Project Analysis and Setup - -### Initial Assessment - -- [x] Review current Flask application structure in `/src/web/` directory -- [x] Identify all Flask routes and their HTTP methods -- [x] Document current template engine usage (Jinja2) -- [x] List all static file serving requirements -- [x] Inventory all middleware and extensions currently used -- [x] Document current error handling patterns -- [x] Review authentication/authorization mechanisms - -### FastAPI Setup - -- [x] Install FastAPI dependencies: `pip install fastapi uvicorn jinja2 python-multipart` -- [x] Update `requirements.txt` or `pyproject.toml` with new dependencies -- [x] Remove Flask dependencies: `flask`, `flask-*` packages -- [x] Create new FastAPI application entry point - -## ๐Ÿ”ง Core Application Migration - -### Main Application Structure - -- [x] Create new `main.py` or update existing app entry point with FastAPI app instance -- [x] Migrate Flask app configuration to FastAPI settings using Pydantic BaseSettings -- [x] Convert Flask blueprints to FastAPI routers -- [x] Update CORS configuration from Flask-CORS to FastAPI CORS middleware - -### Route Conversion - -- [x] Convert all `@app.route()` decorators to FastAPI route decorators (`@app.get()`, `@app.post()`, etc.) -- [x] Update route parameter syntax from `` to `{id: int}` format -- [x] Convert Flask request object usage (`request.form`, `request.json`) to FastAPI request models -- [x] Update response handling from Flask `jsonify()` to FastAPI automatic JSON serialization -- [x] Convert Flask `redirect()` and `url_for()` to FastAPI equivalents - -### Request/Response Models - -- [x] Create Pydantic models for request bodies (replace Flask request parsing) -- [x] Create Pydantic models for response schemas -- [x] Update form handling to use FastAPI Form dependencies -- [x] Convert file upload handling to FastAPI UploadFile - -## ๐ŸŽจ Template and Static Files Migration - -### Template Engine Setup - -- [x] Configure Jinja2Templates in FastAPI application -- [x] Set up template directory structure -- [x] Create templates directory configuration in FastAPI app - -### HTML Template Migration - -- [x] Review all `.html` files in templates directory -- [x] Update template rendering from Flask `render_template()` to FastAPI `templates.TemplateResponse()` -- [x] Verify Jinja2 syntax compatibility (should be mostly unchanged) -- [x] Update template context passing to match FastAPI pattern -- [x] Test all template variables and filters still work correctly - -### Static Files Configuration - -- [x] Configure StaticFiles mount in FastAPI for CSS, JS, images -- [x] Update static file URL generation in templates -- [x] Verify all CSS file references work correctly -- [x] Verify all JavaScript file references work correctly -- [x] Test image and other asset serving - -## ๐Ÿ’ป JavaScript and Frontend Migration - -### Inline JavaScript Review - -- [x] Scan all HTML templates for inline `