Skip to content

Instantly share code, notes, and snippets.

@meelash
Created March 23, 2012 23:35
Show Gist options
  • Select an option

  • Save meelash/2176390 to your computer and use it in GitHub Desktop.

Select an option

Save meelash/2176390 to your computer and use it in GitHub Desktop.
# Client-side:
request = new XMLHttpRequest()
request.open('GET', "http://lakjsdflkjasld:asdf@127.0.0.1:1337/#{path}?#{cacheDiffString()}", true)
request.responseType = 'text'
request.onreadystatechange = ->
console.log request.response
request.send()
# Server-side:
(http.createServer (req, res)->
console.log(req)
if req.url is '/'
res.writeHead 200, 'Content-Type': 'text/html'
res.end index
else if req.url is '/client.js'
clientJs = fs.readFileSync './client.js'
res.writeHead 200, 'Content-Type' : 'text/script'
res.end clientJs
else
parsedUrl = url.parse req.url, yes
console.log parsedUrl
if parsedUrl.auth?
path = parsedUrl.pathname
).listen 1337, '127.0.0.1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment