From b54da611210c8ff7a6284c51333826c143bdda57 Mon Sep 17 00:00:00 2001 From: Aherobo Ovie Victor Date: Fri, 11 Jul 2025 21:31:59 +0100 Subject: [PATCH] Add API documentation access and improve docs integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Enhanced API Documentation Access: - Added /docs route to main app with instructions for Swagger UI - Created helpful documentation page with setup instructions - Added API Documentation button to web interface - Updated /api endpoint to include Swagger UI information ✅ User-Friendly Documentation: - Clear step-by-step instructions to access Swagger UI - Direct link to Swagger UI (when running) - Quick API reference on docs page - Professional styling for documentation page ✅ Improved Navigation: - Added 'API Documentation' button to main interface - Opens in new tab for easy reference - Back link to main interface - Clear visual hierarchy and instructions Now users can easily access API documentation from the main interface --- main.py | 51 +++++++++++++++++++++++++++++++++++++++++++- templates/index.html | 3 +++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index d1b7800..2879b10 100644 --- a/main.py +++ b/main.py @@ -88,15 +88,64 @@ def api_info(): 'endpoints': { '/': 'GET - Frontend interface or API information', '/api': 'GET - API information (JSON)', + '/docs': 'GET - API documentation (Swagger UI)', '/detect': 'POST - Upload image for memory module detection', '/detect/hardcoded': 'GET - Process hardcoded test image', '/detect/base64': 'POST - Process base64 encoded image', '/health': 'GET - Health check' }, 'model_loaded': detector.model is not None, - 'supported_formats': list(ALLOWED_EXTENSIONS) + 'supported_formats': list(ALLOWED_EXTENSIONS), + 'swagger_ui': 'http://localhost:5003/docs/ (run: python3 api_docs.py)' }) +@app.route('/docs') +def api_docs(): + """Redirect to API documentation.""" + return """ + + + + API Documentation + + + +
+

🚀 Memory Module Detection API Documentation

+

Interactive Swagger UI documentation for all API endpoints

+ +

📖 Access Swagger UI:

+
+ Step 1: Start API docs server
+ python3 api_docs.py

+ Step 2: Open Swagger UI
+ http://localhost:5003/docs/ +
+ + + 📚 Open Swagger UI (if running) + + +

📋 Quick API Reference:

+ + +

← Back to Main Interface

+
+ + + """ + @app.route('/health', methods=['GET']) def health_check(): """Health check endpoint.""" diff --git a/templates/index.html b/templates/index.html index 9607cd5..1fbdb2c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -39,6 +39,9 @@ + + API Documentation +