       data = require filename
       # delete require.cache[filename]#require.resolve('./path/to.ext')
     catch err
-      data = {}
-    data = data req if util.isFunction data
-    res.json data
+      data = conf.default
+    res.json if util.isFunction data then data req else data
 
-  app.listen conf.port
-  console.log 'Server running at http://localhost:' + conf.port
+  app.listen conf.port, conf.hostname
+
+  hostname = if conf.hostname then conf.hostname else 'localhost'
+  console.log 'Server running at http://' + hostname + ':' + conf.port

  app = express()
  app.set 'x-powered-by', false

  do ->
    for route, data of conf.api
      app.get route, do (data)->
          (req, res)->
            data = data req if util.isFunction data
            res.json data

  if conf.admin && conf.admin.path
    admin = require './admin/'
    app.use conf.admin.path, admin conf

  app.get '*', (req, res)->
    filename = path.join conf.basedir, conf.src, req.path

module.exports = (conf)->
  conf = util._extend
    port: 8888
    hostname: null
    basedir: process.cwd()
    origin: '*'
    default: {}
    api: {}
    src: ''
    admin:
      path: null
