     if res.headersSent
       return
 
-server = http
-  .createServer app
-  .listen 80
+wifi.getAPIP (cfg) ->
+  ssid = "TT#{cfg.mac.split(':').join('')}"
+  pwd = "12345678"
+  wifi.startAP ssid, password: pwd, ->
+    http
+      .createServer app
+      .listen 80

        if @matchUrl req
          @destroy req, res

  constructor: (opts) ->
    @url = opts.url

  create: (req, res) ->
    notFound res


http = require 'http'
wifi = require 'Wifi'

class Ctrl
  constructor: (opts) ->
    @headers = 'Content-Type': 'application/json'
    @url = opts.url

  matchUrl: (req) ->
    req.url == @url
