diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5efd53f Binary files /dev/null and b/.DS_Store differ diff --git a/app.py b/app.py index 84f90ed..cc2501f 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,19 @@ app = Flask(__name__) CORS(app) # Enable CORS for all routes +@app.route('/', methods=['GET']) +def health_check(): + """ + Health check endpoint for Kubernetes liveness/readiness probes. + Returns: JSON with service status + """ + return jsonify({ + 'status': 'healthy', + 'service': 'RNA Alignment API', + 'environment': os.getenv('ENVIRONMENT', 'unknown') + }), 200 + + @app.route('/', methods=['GET']) def get_msa_data(identifier): """ @@ -18,6 +31,14 @@ def get_msa_data(identifier): URL pattern: /{identifier} Returns: JSON data structure ready for MSA viewer consumption """ + # Prevent health check route from being treated as an identifier + if identifier in ['health', 'favicon.ico']: + return jsonify({ + 'status': 'error', + 'message': 'Invalid identifier', + 'data': None + }), 400 + try: # Get .sto file content from S3 sto_content = get_seed_file_from_s3(identifier) @@ -40,7 +61,8 @@ def get_msa_data(identifier): 'identifier': identifier, 'consensus': msa_data['consensus'], 'notation': msa_data.get('notation'), - 'sequences': msa_data.get('sequences') + 'sequences': msa_data.get('sequences'), + 'sequenceCount': len(msa_data.get('sequences', [])) } }