Skip to content

Instantly share code, notes, and snippets.

@cybear
Created December 9, 2011 08:22
Show Gist options
  • Save cybear/1450723 to your computer and use it in GitHub Desktop.
Save cybear/1450723 to your computer and use it in GitHub Desktop.
Node server for checking if word exists in sowpods
var sowpods = require('./sowpods.js').sowpods;
var server = require('http').createServer(function(req,res){
var word=req.url.replace('/','');
var found=(sowpods.indexOf(word)!==-1);
res.writeHead(200,{
'Content-Type':'application/json',
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Headers':'X-Requested-With'
});
res.end('{"found":'+found+',"word":"'+word+'"}');
});
var port = process.env.PORT || 3000;
server.listen(port, function() {
console.log("Listening on " + port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment