-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (24 loc) · 923 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var app = require('express').createServer();
app.get('/', function(req, res) {
//res.send("<h1> Hello Anton!!!! </h1>");
var pg = require('pg');
var connection_string = 'postgres://mxzuyoxrjiarxk:zDcbCqPyCmEW2gvbv0cKj_KQrW@ec2-54-204-39-67.compute-1.amazonaws.com:5432/d78eqo5u517mq';
pg.connect(connection_string, function(err, client) {
if (err) throw err;
console.log('Connected to postgres! Getting schemas...');
client
.query('SELECT table_schema,table_name FROM information_schema.tables;')
.on('row', function(row) {
console.log(JSON.stringify(row));
res.send("<h1> Created By </h1><hr/>" + JSON.stringify(row));
});
});
});
app.get('/dbrequest', function(req, res)
{
//res.send("<h1> Hello Anton!!!! </h1>");
res.send( "<hr/> query = " + req.query.q);
});
app.listen(process.env.PORT || 3000, function() {
console.log("listening on 3000");
});