Forked from twilson63/jackhq-heroku-nodejs-example.coffee
Created
August 26, 2010 01:12
-
-
Save emerleite/550605 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require.paths.unshift 'express/lib' | |
require 'express' | |
http: require 'express/http' | |
get '/', -> | |
this.contentType 'html' | |
this.respond 200, ''' | |
<html> | |
<head><title>NodeJs Example</title></head> | |
<body> | |
<h1>NodeJs ROCKS</h1> | |
<a href="/nodejs">http://jackhq-node-hw.heroku.com/nodejs</a> | |
<br /> | |
<p>place any string at the end of the url and it will search | |
twitter for the 20 most recent tweets.</p> | |
<p style="margin-top:50px"> | |
<a href="http://www.jackhq.com"">Jack Russell Software</a> | |
</p> | |
<p>Source located <a href="">here</a></p> | |
</body> | |
</html> | |
''' | |
get '/*', (q) -> | |
http.get('http://search.twitter.com/search.json?q=' + q || 'nodejs', (err, content, response) => | |
#if (err) throw err | |
r = '' | |
for m in JSON.parse(content).results | |
r = r + m.text + "<br />" | |
this.contentType 'html' | |
this.respond(200, r) | |
) | |
run(parseInt(process.env.PORT || 8000), null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment