out.end css
js_handler = (args, out, request, url_parts) ->
- fs.readFile 'client.coffee', 'utf8', (err, data) ->
+ basename = url_parts.pathname.substr 1, (url_parts.pathname.length - 4)
+ if basename is 'client'
+ filename = 'client.coffee'
+ else if basename is 'common'
+ filename = 'common.coffee'
+ else
+ error = "Unknown js basename: #{basename}"
+ console.log error
+ out.end(error)
+ return
+
+ fs.readFile filename, 'utf8', (err, data) ->
if err
- return out.end 'Server failed to read client.coffee'
+ return out.end "Server failed to read #{filename}"
out.end coffee.compile data
html_handler = (args, out, request, url_parts) ->