Skip to content

Instantly share code, notes, and snippets.

@booo
Created September 2, 2011 13:05
Show Gist options
  • Save booo/1188554 to your computer and use it in GitHub Desktop.
Save booo/1188554 to your computer and use it in GitHub Desktop.
pg = require "pg"
http = require "http"
s = "postgres://postgres:testing@localhost:5432/testing"
(http.createServer (req, res) ->
pg.connect s, (error, client) ->
if error
console.log error
else
client.query "SELECT NOW();", (error, result) ->
if error then console.log error
else
res.writeHead 200
res.write result.rows
res.end()
).listen 1337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment