Skip to content

Instantly share code, notes, and snippets.

@damieng
Created July 20, 2016 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damieng/81e1db0aa109fa041c35628481b93506 to your computer and use it in GitHub Desktop.
Save damieng/81e1db0aa109fa041c35628481b93506 to your computer and use it in GitHub Desktop.
Grunt http server in Coffeescript
http = require('http')
module.exports = (grunt) ->
grunt.registerTask 'local-crash-reporter', 'Start a local crash reporter server.', ->
PORT = 1127
done = this.async()
server = http.createServer (request, response) ->
if request.method is 'POST'
body = []
request.on 'data', (chunk) ->
body.push(chunk)
request.on 'end', ->
grunt.log.write "\nPOST to #{request.url} with BODY of;\n"
grunt.log.write Buffer.concat(body).toString()
grunt.log.write "\n"
response.end()
server.listen PORT, ->
grunt.log.write "Local crash reporter listening on http://localhost:#{PORT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment