Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emerleite/550605 to your computer and use it in GitHub Desktop.
Save emerleite/550605 to your computer and use it in GitHub Desktop.
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