From 67ce1eb7b73ea1b9eb65ebd5f94301b7df8d7c5b Mon Sep 17 00:00:00 2001 From: iBaa Date: Sun, 10 Nov 2013 14:10:33 +0100 Subject: [PATCH] serving *.js: answer request to main.js with sending application.js, ignoring path --- WebServer.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/WebServer.py b/WebServer.py index db475ae71..a18b5a0f6 100755 --- a/WebServer.py +++ b/WebServer.py @@ -137,9 +137,16 @@ def do_GET(self): return # serve .js files to aTV - if self.path.endswith(".js"): - dprint(__name__, 1, "serving " + sys.path[0] + sep + "assets" + self.path.replace('/',sep).replace('appletv\us\\', '').replace('appletv/us/', '')) - f = open(sys.path[0] + sep + "assets" + self.path.replace('/',sep).replace('appletv\us\\', '').replace('appletv/us/', '')) + # application, main: ignore path, send /assets/js/application.js + # otherwise: path should be '/js', send /assets/js/*.js + dirname = path.dirname(self.path) + basename = path.basename(self.path) + if basename in ("application.js", "main.js") or \ + basename.endswith(".js") and dirname == '/js': + if basename == "main.js": + basename = "application.js" + dprint(__name__, 1, "serving /js/{0}", basename) + f = open(sys.path[0] + "/assets/js/" + basename) self.send_response(200) self.send_header('Content-type', 'text/javascript') self.end_headers()