File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88from utils .recommender import get_recommendations , validate_recommendation_inputs
99from utils .data_loader import find_project_by_id , get_project_stats
1010from utils .file_server import read_starter_code , resolve_starter_file , get_starter_code_dir
11+ import os
1112
1213# Create the Blueprint that app.py will register
1314main = Blueprint ("main" , __name__ )
@@ -19,6 +20,16 @@ def index():
1920 stats = get_project_stats ()
2021 return render_template ("index.html" , stats = stats )
2122
23+ @main .route ("/health" )
24+ def health_check ():
25+ """
26+ Returns server status. Useful for uptime monitors and Docker health checks.
27+ """
28+ return jsonify ({
29+ "status" : "ok" ,
30+ "version" : os .getenv ("APP_VERSION" , "1.0.0" )
31+ }), 200
32+
2233
2334@main .route ("/api/recommend" , methods = ["POST" ])
2435def recommend ():
Original file line number Diff line number Diff line change @@ -279,6 +279,14 @@ def test_download_code_found():
279279 client = get_client ()
280280 response = client .get ("/project/1/download" )
281281 assert response .status_code == 200
282+
283+ def test_health_check (client ):
284+ response = client .get ("/health" )
285+ assert response .status_code == 200
286+ data = response .get_json ()
287+ assert "status" in data
288+ assert "version" in data
289+ assert data ["status" ] == "ok"
282290
283291
284292from utils .recommender import SCORING_WEIGHTS
You can’t perform that action at this time.
0 commit comments