From 2f9a198f045d6181a28c97d6784f4ea0ecd8cfe7 Mon Sep 17 00:00:00 2001 From: pmustonebi Date: Wed, 26 Nov 2025 11:47:47 +0000 Subject: [PATCH] Updated to add sequenceCount and healthcheck --- .DS_Store | Bin 0 -> 6148 bytes app.py | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5efd53fa377be31a6a3116f1c67080f22334e617 GIT binary patch literal 6148 zcmeHLzb^zq6n^6t_aj89P)z7Au2U{KiG)t5B+em-TYKRU-Tnvu0a}$plqwa4ny6@0 zDy2lh_hu$;=I)kGE;8>j^XKvMRB=Yt;JRNvL`bamoLTJ zNq2nh$MO26H8Wz-i>@mCc(%jwqXTdz*CfBaqY22>cHz&Dnw;R@MwroM8 z@4W(E0k6Qf0z5xRG{(?iqESs9=+qVf7{ILz$7;?8N_GH4gNa6XU_z$?b*eC1458EE zmnJSWm}u1LBvfUb$5a+(hayyU_@xRb5o+|kSHLUaDv;4%hj{&;PT&8#N&cHxz$@^t z6c9mqzC49XGHYww#qnAz(JE+c9G7TRDd@~{tPXf7=KmFxVNCJ?Ff^EGga_t-2q+nR K=N0%<1-<}A9MR(d literal 0 HcmV?d00001 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', [])) } }