Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require('http'),
- mysql = require("mysql");
- var connection = mysql.createConnection({
- user: "root",
- password: "",
- database: "db_name"
- });
- http.createServer(function (request, response) {
- request.on('end', function () {
- connection.query('SELECT * FROM your_table;', function (error, rows, fields) {
- response.writeHead(200, {
- 'Content-Type': 'x-application/json'
- });
- response.end(JSON.stringify(rows));
- });
- });
- }).listen(8080);
Add Comment
Please, Sign In to add comment