from flask import Flask, request, jsonify from flask_cors import CORS from text_to_blendshapes_service import TextToBlendShapesService app = Flask(__name__) CORS(app) @app.route('/health', methods=['GET']) def health(): return jsonify({'status': 'ok'}) @app.route('/text-to-blendshapes', methods=['POST']) def text_to_blendshapes(): try: data = request.get_json() if not data or 'text' not in data: return jsonify({'success': False, 'error': 'Missing text'}), 400 text = data['text'] language = data.get('language', 'zh-CN') service = TextToBlendShapesService(lang=language) result = service.text_to_blend_shapes(text) return jsonify(result) except Exception as e: import traceback traceback.print_exc() return jsonify({'success': False, 'error': str(e)}), 500 if __name__ == '__main__': print("Text to BlendShapes API: http://localhost:5001") app.run(host='0.0.0.0', port=5001, debug=True)