Created
April 4, 2017 15:37
-
-
Save obowersa/9a15aa0d47df4166f62eef939a82e77d 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
var http = require('http'); | |
var mysql = require('mysql'); | |
var connection = mysql.createConnection({ | |
host: 'localhost', | |
user: 'root', | |
database: 'node' | |
}); | |
console.log('MySQL Connection details '+connection); | |
http.createServer(function (request, response) | |
{ | |
console.log('Creating the http server'); | |
connection.query('SELECT id, content FROM test WHERE id IN (?,?)',[1, 2], function(err, rows, fields) | |
{ | |
response.writeHead(200, { 'Content-Type': 'application/json'}); | |
response.end(JSON.stringify(rows)); | |
response.end(); | |
}); | |
}).listen(8084); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment