duqing2026's picture
Enhance: Localize assets, add Import/Export JSON, fix potential 500 errors
9ce39b3
raw
history blame contribute delete
802 Bytes
import os
from flask import Flask, render_template
app = Flask(__name__)
# Jinja2 configuration to avoid conflict with Vue
app.jinja_env.variable_start_string = '[['
app.jinja_env.variable_end_string = ']]'
app.jinja_env.block_start_string = '[%'
app.jinja_env.block_end_string = '%]'
@app.route('/')
def index():
return render_template('index.html')
@app.route('/healthz')
def healthz():
return "ok"
@app.errorhandler(404)
def page_not_found(e):
return "404 Not Found", 404
@app.errorhandler(500)
def internal_server_error(e):
return f"500 Internal Server Error: {str(e)}", 500
if __name__ == '__main__':
try:
port = int(os.environ.get('PORT', 7860))
app.run(host='0.0.0.0', port=port)
except Exception as e:
print(f"Error starting server: {e}")