Skip to content

Commit

Permalink
Fromating
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneGudermann committed Nov 6, 2024
1 parent 139d198 commit 2983910
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/app_server/app_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from wsgiref.types import StartResponse, WSGIEnvironment

from werkzeug.wrappers import Request, Response


class AppWrapper:
"""simple wrapping app"""

Expand Down
16 changes: 6 additions & 10 deletions src/app_server/shared_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ def __call__(
file_loader = None

for search_path, loader in self.exports:
# lets check for regex, and inject real_path
# let's check for regex, and inject real_path
if re.match(search_path, path):
real_path = re.sub(search_path, self.org_exports[search_path],
path, 1)
real_filename, file_loader = self.get_file_loader(real_path)(
None)
real_path = re.sub(search_path, self.org_exports[search_path],path, 1)
real_filename, file_loader = self.get_file_loader(real_path)(None)

if file_loader is not None:
break
Expand All @@ -66,8 +64,7 @@ def __call__(
return self.app(environ, start_response)

guessed_type = mimetypes.guess_type(real_filename) # type: ignore
mime_type = get_content_type(guessed_type[0] or self.fallback_mimetype,
"utf-8")
mime_type = get_content_type(guessed_type[0] or self.fallback_mimetype,"utf-8")

try:
f, mtime, file_size = file_loader()
Expand All @@ -77,20 +74,19 @@ def __call__(
headers = [("Date", http_date())]

if self.cache:
timeout = self.cache_timeout
etag = self.generate_etag(mtime, file_size,
real_filename) # type: ignore
headers += [
("Etag", f'"{etag}"'),
("Cache-Control", f"max-age={timeout}, public"),
("Cache-Control", f"max-age={self.cache_timeout}, public"),
]

if not is_resource_modified(environ, etag, last_modified=mtime):
f.close()
start_response("304 Not Modified", headers)
return []

headers.append(("Expires", http_date(time.time() + timeout)))
headers.append(("Expires", http_date(time.time() + self.cache_timeout)))
else:
headers.append(("Cache-Control", "public"))

Expand Down

0 comments on commit 2983910

Please sign in to comment.