diff --git a/src/service/api/views/html/static.py b/src/service/api/views/html/static.py index ad58c4d..cbfb456 100644 --- a/src/service/api/views/html/static.py +++ b/src/service/api/views/html/static.py @@ -12,11 +12,21 @@ from aiohttp.web import HTTPNotFound, Response, View class StaticHtmlView(View): + def __get_content_type(self, filename: str) -> str: + _, ext = os.path.splitext(filename) + print(ext) + if ext == '.css': + return 'text/css' + elif ext == '.js': + return 'text/javascript' + return 'text/plain' + async def get(self) -> Response: resource_name = self.request.match_info['resource_id'] resource_path = os.path.join(self.request.app['templates_root'], 'static', resource_name) if not os.path.exists(resource_path) or os.path.isdir(resource_path): return HTTPNotFound() + content_type = self.__get_content_type(resource_name) with open(resource_path) as resource_file: - return Response(text=resource_file.read(), content_type='text/css') \ No newline at end of file + return Response(text=resource_file.read(), content_type=content_type) \ No newline at end of file diff --git a/templates/bis.jinja2 b/templates/bis.jinja2 index 99ed6a5..62fb10a 100644 --- a/templates/bis.jinja2 +++ b/templates/bis.jinja2 @@ -4,6 +4,7 @@