✨ New Features: - Complete backup lifecycle management (create, list, download, delete, cleanup) - Web-based backup interface with real-time status updates - Individual backup deletion and bulk cleanup for old backups - Docker-aware backup operations with volume persistence - Automated backup scheduling and retention policies 📁 Added Files: - backup.py - Core backup script for creating timestamped archives - docker_backup.sh - Docker-compatible backup wrapper script - app/templates/backup.html - Web interface for backup management - BACKUP_SYSTEM.md - Comprehensive backup system documentation - BACKUP_GUIDE.md - Quick reference guide for backup operations 🔧 Enhanced Files: - Dockerfile - Added backup.py copy for container availability - docker-compose.yml - Added backup volume mount for persistence - app/routes/api.py - Added backup API endpoints (create, list, delete, cleanup) - app/routes/main.py - Added backup management route - app/templates/index.html - Added backup management navigation - README.md - Updated with backup system overview and quick start 🎯 Key Improvements: - Fixed backup creation errors in Docker environment - Added Docker-aware path detection for container operations - Implemented proper error handling and user confirmation dialogs - Added real-time backup status updates via JavaScript - Enhanced data persistence with volume mounting 💡 Use Cases: - Data protection and disaster recovery - Environment migration and cloning - Development data management - Automated maintenance workflows
75 lines
2.2 KiB
Python
Executable File
75 lines
2.2 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('/backup')
|
|
@login_required
|
|
def backup_management():
|
|
"""Display the backup management page"""
|
|
return render_template('backup.html')
|
|
|
|
@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)
|