merge-requests/30/head
Bob Mottram 2024-04-08 15:08:19 +01:00
parent c60fb9b467
commit 3cc575bb85
2 changed files with 12 additions and 7 deletions

View File

@ -1270,7 +1270,10 @@ def daemon_http_get(self) -> None:
if self.path.endswith('.css'): if self.path.endswith('.css'):
if get_style_sheet(self, self.server.base_dir, if get_style_sheet(self, self.server.base_dir,
calling_domain, self.path, calling_domain, self.path,
getreq_start_time): getreq_start_time,
self.server.debug,
self.server.css_cache,
self.server.fitness):
return return
if authorized and '/exports/' in self.path: if authorized and '/exports/' in self.path:

View File

@ -20,7 +20,9 @@ from daemon_utils import etag_exists
def get_style_sheet(self, base_dir: str, calling_domain: str, path: str, def get_style_sheet(self, base_dir: str, calling_domain: str, path: str,
getreq_start_time) -> bool: getreq_start_time, debug: bool,
css_cache: {},
fitness: {}) -> bool:
"""Returns the content of a css file """Returns the content of a css file
""" """
# get the last part of the path # get the last part of the path
@ -29,15 +31,15 @@ def get_style_sheet(self, base_dir: str, calling_domain: str, path: str,
path = path.split('/')[-1] path = path.split('/')[-1]
path = base_dir + '/' + path path = base_dir + '/' + path
css = None css = None
if self.server.css_cache.get(path): if css_cache.get(path):
css = self.server.css_cache[path] css = css_cache[path]
elif os.path.isfile(path): elif os.path.isfile(path):
tries = 0 tries = 0
while tries < 5: while tries < 5:
try: try:
css = get_css(base_dir, path) css = get_css(base_dir, path)
if css: if css:
self.server.css_cache[path] = css css_cache[path] = css
break break
except BaseException as ex: except BaseException as ex:
print('EX: _get_style_sheet ' + path + ' ' + print('EX: _get_style_sheet ' + path + ' ' +
@ -51,9 +53,9 @@ def get_style_sheet(self, base_dir: str, calling_domain: str, path: str,
None, calling_domain, False) None, calling_domain, False)
write2(self, msg) write2(self, msg)
fitness_performance(getreq_start_time, fitness_performance(getreq_start_time,
self.server.fitness, fitness,
'_GET', '_get_style_sheet', '_GET', '_get_style_sheet',
self.server.debug) debug)
return True return True
http_404(self, 92) http_404(self, 92)
return True return True