Spaces:
Sleeping
Sleeping
| import os | |
| from flask import Flask, render_template, send_from_directory, jsonify | |
| app = Flask(__name__, static_folder='static', template_folder='templates') | |
| def index(): | |
| try: | |
| return render_template('index.html') | |
| except Exception as e: | |
| return jsonify({"error": str(e), "message": "Template rendering failed. Please check server logs."}), 500 | |
| def health(): | |
| return jsonify({"status": "ok", "service": "carousel-maker-pro"}) | |
| def serve_static(path): | |
| return send_from_directory('static', path) | |
| def internal_error(error): | |
| return jsonify({"error": "Internal Server Error", "details": str(error)}), 500 | |
| def not_found(error): | |
| return jsonify({"error": "Not Found", "path": str(error)}), 404 | |
| if __name__ == '__main__': | |
| # Use 7860 for Hugging Face Spaces | |
| port = int(os.environ.get('PORT', 7860)) | |
| app.run(host='0.0.0.0', port=port) | |