Created
December 9, 2011 08:22
-
-
Save cybear/1450723 to your computer and use it in GitHub Desktop.
Node server for checking if word exists in sowpods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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