- Added environment variable loading with python-dotenv - Fixed Docker session permissions by using /tmp directory - Updated .dockerignore to include .env file properly - Enhanced docker-compose.yml with env_file directive - Fixed Gunicorn configuration for Docker compatibility - Updated README.md with comprehensive deployment docs - Cleaned up debug logging from API routes - Added DOMAIN_SETUP.md for reverse proxy guidance - All production issues resolved and tested working - Application now accessible at qr.moto-adv.com
56 lines
1.5 KiB
Python
Executable File
56 lines
1.5 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
|
|
|
|
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"""
|
|
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('link_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"""
|
|
original_url = link_manager.resolve_short_url(short_code)
|
|
if original_url:
|
|
return redirect(original_url)
|
|
else:
|
|
abort(404)
|