4646urls = (
4747 "/" , "Main" ,
4848 "/static/(.*)" , "Static" ,
49+ "/health" , "Health" ,
4950 "/meta" , "SparqlMeta" ,
5051 '/favicon.ico' , 'Favicon' ,
5152 "/index" , "SparqlIndex"
5253)
5354
5455# Set the web logger
55- web_logger = WebLogger (env_config ["base_url" ], env_config ["log_dir" ], [
56- "HTTP_X_FORWARDED_FOR" , # The IP address of the client
57- "REMOTE_ADDR" , # The IP address of internal balancer
58- "HTTP_USER_AGENT" , # The browser type of the visitor
59- "HTTP_REFERER" , # The URL of the page that called your program
60- "HTTP_HOST" , # The hostname of the page being attempted
61- "REQUEST_URI" , # The interpreted pathname of the requested document
62- # or CGI (relative to the document root)
63- "HTTP_AUTHORIZATION" , # Access token
64- ],
65- # comment this line only for test purposes
66- {"REMOTE_ADDR" : ["130.136.130.1" , "130.136.2.47" , "127.0.0.1" ]}
67- )
56+ # web_logger = WebLogger(env_config["base_url"], env_config["log_dir"], [
57+ # "HTTP_X_FORWARDED_FOR", # The IP address of the client
58+ # "REMOTE_ADDR", # The IP address of internal balancer
59+ # "HTTP_USER_AGENT", # The browser type of the visitor
60+ # "HTTP_REFERER", # The URL of the page that called your program
61+ # "HTTP_HOST", # The hostname of the page being attempted
62+ # "REQUEST_URI", # The interpreted pathname of the requested document
63+ # # or CGI (relative to the document root)
64+ # "HTTP_AUTHORIZATION", # Access token
65+ # ],
66+ # # comment this line only for test purposes
67+ # {"REMOTE_ADDR": ["130.136.130.1", "130.136.2.47", "127.0.0.1"]}
68+ # )
6869
6970render = web .template .render (c ["html" ], globals = {
7071 'str' : str ,
@@ -102,6 +103,12 @@ def GET(self):
102103 )
103104 protocol = 'https' if is_https else 'http'
104105 raise web .seeother (f"{ protocol } ://{ web .ctx .host } /static/favicon.ico" )
106+
107+ class Health :
108+ """Lightweight health check endpoint for Kubernetes probes"""
109+ def GET (self ):
110+ web .header ('Content-Type' , 'application/json' )
111+ return '{"status": "ok"}'
105112
106113class Header :
107114 def GET (self ):
@@ -116,7 +123,7 @@ def __init__(self, sparql_endpoint, sparql_endpoint_title, yasqe_sparql_endpoint
116123 self .collparam = ["query" ]
117124
118125 def GET (self ):
119- web_logger .mes ()
126+ # web_logger.mes()
120127 content_type = web .ctx .env .get ('CONTENT_TYPE' )
121128 return self .__run_query_string (self .sparql_endpoint_title , web .ctx .env .get ("QUERY_STRING" ), content_type )
122129
@@ -158,7 +165,7 @@ def __contact_tp(self, data, is_post, content_type):
158165 web .header ('Content-Type' , 'application/sparql-results+json' )
159166 else :
160167 web .header ('Content-Type' , req .headers ["content-type" ])
161- web_logger .mes ()
168+ # web_logger.mes()
162169 req .encoding = "utf-8"
163170 return req .text
164171 else :
@@ -179,7 +186,7 @@ def __run_query_string(self, active, query_string, is_post=False,
179186 parsed_query = urlparse .parse_qs (query_string )
180187 current_subdomain = web .ctx .host .split ('.' )[0 ].lower ()
181188 if query_string is None or query_string .strip () == "" :
182- web_logger .mes ()
189+ # web_logger.mes()
183190 return getattr (render , self .sparql_endpoint_title )(
184191 active = active ,
185192 sp_title = self .sparql_endpoint_title ,
@@ -210,7 +217,7 @@ def __run_query_string(self, active, query_string, is_post=False,
210217
211218class Main :
212219 def GET (self ):
213- web_logger .mes ()
220+ # web_logger.mes()
214221 current_subdomain = web .ctx .host .split ('.' )[0 ].lower ()
215222 return render .sparql (active = "" , sp_title = "" , sparql_endpoint = "" , current_subdomain = current_subdomain , render = render )
216223
0 commit comments