✅ Fixed Critical Issues: - Fixed dynamic QR code short URL redirect functionality - Resolved data consistency issues with multiple LinkPageManager instances - Fixed worker concurrency problems in Gunicorn configuration 🎨 UI/UX Enhancements: - Separated public page from admin statistics view - Created clean public_page.html for QR code users (no admin info) - Added comprehensive statistics_page.html for admin analytics - Enhanced dashboard with separate 'Manage' and 'Stats' buttons - Improved navigation flow throughout the application 🔧 Technical Improvements: - Added URLShortener instance reloading for data consistency - Reduced Gunicorn workers to 1 to prevent file conflicts - Increased timeout to 60s for better performance - Enhanced debug logging for troubleshooting - Added proper error handling and 404 responses 📁 New Files: - app/templates/public_page.html - Clean public interface - app/templates/statistics_page.html - Admin analytics dashboard �� Modified Files: - app/routes/main.py - Added /stats route, improved short URL handling - app/templates/edit_links.html - Added Statistics button - app/templates/index.html - Added Stats button for QR codes - app/utils/link_manager.py - Enhanced data reloading - app/utils/url_shortener.py - Added debug logging - gunicorn.conf.py - Optimized worker configuration This update provides a professional separation between public content and admin functionality while ensuring reliable short URL operation.
69 lines
2.0 KiB
Python
Executable File
69 lines
2.0 KiB
Python
Executable File
"""
|
|
Main routes for QR Code Manager
|
|
"""
|
|
|
|
from flask import Blueprint, render_template, redirect, abort
|
|
from app.utils.auth import login_required
|
|
from app.utils.link_manager import LinkPageManager
|
|
from app.utils.url_shortener import URLShortener
|
|
|
|
bp = Blueprint('main', __name__)
|
|
|
|
# Initialize manager
|
|
link_manager = LinkPageManager()
|
|
|
|
@bp.route('/')
|
|
@login_required
|
|
def index():
|
|
"""Serve the main page"""
|
|
return render_template('index.html')
|
|
|
|
@bp.route('/links/<page_id>')
|
|
def view_link_page(page_id):
|
|
"""Display the public link page (for QR codes)"""
|
|
if not link_manager.page_exists(page_id):
|
|
return "Page not found", 404
|
|
|
|
link_manager.increment_view_count(page_id)
|
|
page_data = link_manager.get_page(page_id)
|
|
|
|
return render_template('public_page.html', page=page_data)
|
|
|
|
@bp.route('/stats/<page_id>')
|
|
@login_required
|
|
def view_page_statistics(page_id):
|
|
"""Display the statistics page for admins"""
|
|
if not link_manager.page_exists(page_id):
|
|
return "Page not found", 404
|
|
|
|
page_data = link_manager.get_page(page_id)
|
|
return render_template('statistics_page.html', page=page_data)
|
|
|
|
@bp.route('/edit/<page_id>')
|
|
@login_required
|
|
def edit_link_page(page_id):
|
|
"""Display the edit interface for the link page"""
|
|
if not link_manager.page_exists(page_id):
|
|
return "Page not found", 404
|
|
|
|
page_data = link_manager.get_page(page_id)
|
|
return render_template('edit_links.html', page=page_data)
|
|
|
|
@bp.route('/health')
|
|
def health_check():
|
|
"""Health check endpoint for Docker"""
|
|
from datetime import datetime
|
|
from flask import jsonify
|
|
return jsonify({'status': 'healthy', 'timestamp': datetime.now().isoformat()})
|
|
|
|
@bp.route('/s/<short_code>')
|
|
def redirect_short_url(short_code):
|
|
"""Redirect short URL to original URL"""
|
|
# Force reload of data to ensure we have the latest short URLs
|
|
link_manager.url_shortener = URLShortener()
|
|
original_url = link_manager.resolve_short_url(short_code)
|
|
if original_url:
|
|
return redirect(original_url)
|
|
else:
|
|
abort(404)
|