Skip to content

Commit

Permalink
serving *.js: answer request to main.js with sending application.js, …
Browse files Browse the repository at this point in the history
…ignoring path
  • Loading branch information
iBaa committed Nov 10, 2013
1 parent 318e8f2 commit 67ce1eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions WebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 67ce1eb

Please sign in to comment.