Skip to content

Commit

Permalink
use static_root
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Sep 15, 2023
1 parent a53d6f2 commit f56fcc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ save_days = 30
# - '.js': javascript block (with script tag surrounding), included on every page view.
# extra_dir = /path/to/extra/stuff

# URI root for static assets (absolute, but no trailing '/').
static_root = /static
# URI root for static assets (absolute or relative, but no trailing '/').
static_root = static

# How many seconds to allow a check to run for.
max_runtime = 60
Expand Down
3 changes: 2 additions & 1 deletion redbot/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(self, config: SectionProxy) -> None:
thor.schedule(self.watchdog_freq, self.watchdog_ping)

# Read static files
self.static_root = os.path.join("/", config["static_root"]).encode("ascii")
self.static_files = resource_files("redbot.assets")
self.extra_files = {}
if self.config.get("extra_base_dir"):
Expand Down Expand Up @@ -183,7 +184,7 @@ def request_done(self, trailers: RawHeaderListType) -> None:

def serve_static(self, path: bytes) -> None:
path = os.path.normpath(path)
if path.startswith(b"/static/"):
if path.startswith(self.server.static_root):
path = b"/".join(path.split(b"/")[2:])
try:
with self.server.static_files.joinpath(path.decode("ascii")).open(
Expand Down

0 comments on commit f56fcc3

Please sign in to comment.