aboutsummaryrefslogtreecommitdiffstats
path: root/clients.js
blob: f75b5d5211c7422dd221671ed71b0df7c36f54ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var http = require('http');
var mysql = require('mysql');
var url = require('url');

http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  var client = url.parse(req.url, true).query.client;

  var connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : 'MPJzfq97',
    database:  'vanbtc'
  });

  connection.connect();
  connection.query("SELECT * FROM users WHERE login = ?", [client], function(err, rows) {
    res.write(JSON.stringify(rows));
    connection.end();
    res.end();
  });
}).listen(8000);