         if useHTTPS
           Step(
             () ->
-              app.listen config.port, address, this.parallel()
+              appServer.listen config.port, address, this.parallel()
               bounce.listen 80, address, this.parallel(),
             (err) ->
               cb(err, app, bounce)


fs = require "fs"
path = require "path"

_ = require "underscore"
express = require "express"

  localURL.server = server
  localURL.protocol = (if (useHTTPS) then "https" else "http")

  app = express()
  if useHTTPS
    appServer = https.createServer(
      key: fs.readFileSync(config.key)
      cert: fs.readFileSync(config.cert),
      app
    )
    bounce = express.createServer((req, res, next) ->
      host = req.header("Host")
      res.redirect "https://" + host + req.url, 301
    )
  else
    appServer = http.createServer(app)

  # Configuration
  app.set "views", path.join __dirname, "..", "views"
