AnsysLink/app.py

54 lines
1.4 KiB
Python

"""
Main application entry point for CAE Mesh Generator
"""
from flask import Flask, request, jsonify
from config import FLASK_CONFIG
import os
def create_app():
"""Create and configure Flask application"""
app = Flask(__name__,
static_folder='frontend',
static_url_path='')
# Load configuration
app.config.update(FLASK_CONFIG)
# Register API blueprint
from backend.api.routes import api_bp
app.register_blueprint(api_bp, url_prefix='/api')
# Basic route for serving frontend
@app.route('/')
def index():
return app.send_static_file('index.html')
# Error handlers
@app.errorhandler(413)
def too_large(e):
return jsonify({
'success': False,
'error': 'File too large. Maximum size is 100MB.'
}), 413
@app.errorhandler(404)
def not_found(e):
if request.path.startswith('/api/'):
return jsonify({
'success': False,
'error': 'API endpoint not found'
}), 404
return app.send_static_file('index.html')
@app.errorhandler(500)
def internal_error(e):
return jsonify({
'success': False,
'error': 'Internal server error'
}), 500
return app
if __name__ == '__main__':
app = create_app()
app.run(host='0.0.0.0', port=5000, debug=True)