from flask import Flask, request, jsonify from flask_cors import CORS from FINAL_CODE import answer_question app = Flask(__name__) CORS(app) @app.route('/api/ask', methods=['POST']) def ask_question(): try: data = request.get_json() if not data or 'question' not in data: return jsonify({ 'success': False, 'error': 'Question is required' }), 400 question = data['question'] answer = answer_question(question) return jsonify({ 'success': True, 'question': question, 'answer': answer }) except Exception as e: return jsonify({ 'success': False, 'error': str(e) }), 500 if __name__ == '__main__': # Make sure to run with host='0.0.0.0' to be accessible externally if needed app.run(host='0.0.0.0', port=5000, debug=True)