File size: 994 Bytes
76257a0
812e9ed
76257a0
 
 
 
 
9ed069f
 
 
 
76257a0
812e9ed
 
 
 
76257a0
 
 
 
9ed069f
 
 
 
 
 
 
 
76257a0
812e9ed
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from flask import Flask, render_template, send_from_directory, jsonify

app = Flask(__name__, static_folder='static', template_folder='templates')

@app.route('/')
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

@app.route('/health')
def health():
    return jsonify({"status": "ok", "service": "carousel-maker-pro"})

@app.route('/static/<path:path>')
def serve_static(path):
    return send_from_directory('static', path)

@app.errorhandler(500)
def internal_error(error):
    return jsonify({"error": "Internal Server Error", "details": str(error)}), 500

@app.errorhandler(404)
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)