 qs = require 'querystring'
 crypto = require 'crypto'
 Cookies = require 'cookies'
-io = require 'socket.io'
 
 loggedIn = {}
 

            res.write JSON.stringify msg
            res.end()

    if url is '/user/zenozeng'
      json =
        remote: config.remote
        username: "zenozeng"
        key: config.users.zenozeng.key
      base64 = qrcode JSON.stringify(json)
      response "SCAN THE QR CODE", "<img id='qr-code' src='#{base64}' alt='qr'/>"

  server.listen 8080, '0.0.0.0'

      res.write html
      res.end()


    if loggedIn[session]? and loggedIn[session].timestamp < ((new Date()).getTime() - 10*3600)
      # logged in and ignore
      return

    if req.method is 'GET'
      json =
        session: uuid.v1()
        remote: config.remote
      json = JSON.stringify(json)
      base64 = qrcode json
      response "AUTHORIZATION IS NEEDED TO ACCESS", "<img id='qr-code' src='#{base64}' alt='qr'/>
        <form action='' method='post'><input type='text' name='action' value='clone'><input type='submit'></form>"

    if req.method is 'POST'
      body = ''
      req.on 'data', (data) -> body += data
      req.on 'end', ->
        POST = qs.parse body
        {username, hash, session, action} = POST

        console.log POST
        msg = {status: 'success'}
        res.writeHead 200, {'Content-Type': 'text/html'}
        res.write JSON.stringify msg
        res.end()

        if action is 'check'

          console.log {POST: POST}

        else if action is 'auth'

          timestamp = parseInt((new Date().getTime()) / 1000 / 30)

          key = config.users.zenozeng.key
