Skip to content

Instantly share code, notes, and snippets.

@x-bart
Last active August 29, 2015 14:23
Show Gist options
  • Save x-bart/6c518f6f4c021db6a568 to your computer and use it in GitHub Desktop.
Save x-bart/6c518f6f4c021db6a568 to your computer and use it in GitHub Desktop.
app = require('express')()
exec = require('child_process').exec
fs = require 'fs'
app.get "*", (req, resp) ->
file = "." + req.url
if fs.existsSync file
exec "coffee #{file}", (err, stdout, stderr) ->
if err?
resp.status(500).send err
else if stderr? && stderr isnt ""
resp.status(400).send stderr
else
resp.status(200).send stdout
resp.end()
else
resp.status(404).end "404 Not Found"
app.listen 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment