if (port) this.port = port
require('http')
.createServer(function(request, response){
self.request = request
self.response = response
(self.response = response).headers = {}
request.addListener('body', function(chunk){ request.body += chunk })
request.addListener('complete', function(){ self.route() })
})
.listen(this.port, this.host)
puts('Express started at http://' + this.host + ':' + this.port + '/')
},
route: function(){
this.response.body = route(request)
if (typeof this.response.body == 'string')
if (typeof (this.response.body = route(request)) == 'string')
this.respond()
},
respond: function(body){
if (body) this.response.body = body
this.response.sendHeader(200, { 'content-length': 6 })
this.response.sendHeader(200, this.response.headers)
this.response.sendBody(this.response.body || '')
this.response.finish()
}
})