diff options
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -0,0 +1,54 @@ +from flask import Flask, render_template, send_from_directory, jsonify +import os + +# Create the Flask application +app = Flask(__name__, + static_folder='.', + static_url_path='') + +# Configuration +class Config: + DEBUG = True + SECRET_KEY = os.environ.get('SECRET_KEY', 'development-key') + # Add more configuration options as needed + +app.config.from_object(Config) + +# Environment variables to pass to frontend +def get_env_vars(): + """Return environment variables to be passed to the frontend""" + return { + 'thing': 1, + # Add more variables as needed + } + +# Routes +@app.route('/') +def index(): + """Serve the main index.html page""" + return send_from_directory('.', 'index.html') + +# API routes - examples for future expansion +@app.route('/api/env') +def api_env(): + """Return environment variables as JSON""" + return jsonify(get_env_vars()) + +@app.route('/api/health') +def health_check(): + """Health check endpoint""" + return jsonify({'status': 'ok'}) + +# Error handlers +@app.errorhandler(404) +def not_found(e): + return jsonify({'error': 'Not found'}), 404 + +@app.errorhandler(500) +def server_error(e): + return jsonify({'error': 'Server error'}), 500 + +if __name__ == '__main__': + # Get port from environment variable or use 5000 as default + port = int(os.environ.get('PORT', 5000)) + app.run(host='0.0.0.0', port=port) |
