text: var accepts = require('accepts')
  var http = require('http')
  
  function app (req, res) {
    var accept = accepts(req)
  
    // the order of this list is significant; should be server preferred order
    switch (accept.type(['json', 'html'])) {
      case 'json':
        res.setHeader('Content-Type', 'application/json')
        res.write('{"hello":"world!"}')
        break
      case 'html':
        res.setHeader('Content-Type', 'text/html')
        res.write('<b>hello, world!</b>')
        break
      default:
        // the fallback is text/plain, so no need to specify it above
        res.setHeader('Content-Type', 'text/plain')
        res.write('hello, world!')
        break
    }
  
    res.end()
  }
  
  http.createServer(app).listen(3000)
  