from flask import Blueprint, jsonify import requests from config import Config bp = Blueprint('health', __name__, url_prefix='/api') @bp.route('/health', methods=['GET']) def health_check(): """Health check endpoint for monitoring.""" return jsonify({ 'status': 'healthy', 'service': 'nextsnap', 'version': '1.0.0' }), 200 @bp.route('/health/nextcloud', methods=['GET']) def nextcloud_health(): """Check connectivity to Nextcloud instance.""" try: nc_url = Config.NEXTCLOUD_URL response = requests.get(f"{nc_url}/status.php", timeout=5) response.raise_for_status() return jsonify({ 'status': 'healthy', 'nextcloud_url': nc_url, 'nextcloud_reachable': True }), 200 except Exception as e: return jsonify({ 'status': 'degraded', 'nextcloud_url': Config.NEXTCLOUD_URL, 'nextcloud_reachable': False, 'error': str(e) }), 503