Skip to content

Commit

Permalink
Fixing some of the static content
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexarian committed Jan 15, 2025
1 parent 5751d31 commit d2241b6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,12 +821,14 @@ def handle_static_content(self) -> str:
self.path = "/index.html"
content, content_type = get_static(WEB_ROOT, self.path)
status = self.pw.status()
content = content.decode(UTF_8).format(
VERSION=status.get("version", ""),
HASH=status.get("git_hash", ""),
EMAIL=self.configuration[CONFIG_TYPE.PW_EMAIL],
STYLE=self.configuration[CONFIG_TYPE.PW_STYLE],
).encode(UTF_8)
content = content.decode(UTF_8)
# fix the following variables that if they are None, return ""
content = content.replace("{VERSION}", status.get("version", "") or "")
content = content.replace("{HASH}", status.get("git_hash", "") or "")
content = content.replace("{EMAIL}", self.configuration.get(CONFIG_TYPE.PW_EMAIL, "") or "")
content = content.replace("{STYLE}", self.configuration.get(CONFIG_TYPE.PW_STYLE, "") or "")
# convert fcontent back to bytes
content = bytes(content, UTF_8)
else:
content, content_type = get_static(WEB_ROOT, self.path)

Expand All @@ -835,7 +837,7 @@ def handle_static_content(self) -> str:
# If not found, serve from Powerwall web server
elif self.pw.cloudmode or self.pw.fleetapi:
log.debug(f"Cloud Mode - File not found: {self.path}")
content = b"Not Found"
content = bytes("Not Found", UTF_8)
content_type = "text/plain"
else:
# Proxy request to Powerwall web server.
Expand Down

0 comments on commit d2241b6

Please sign in to comment.