Created
October 30, 2016 17:52
-
-
Save Quaggie/be4f1c95b763b738e7e3597290b082d6 to your computer and use it in GitHub Desktop.
This file contains 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
const spawn = require('child_process').spawn; // child_process spawn function | |
const app = require('express')(); // new express http server | |
app.use('/', (req, res) => { | |
const ls = spawn('ls', ['-lh', '/usr']); // here would be the mysqldump command | |
ls.stdout.pipe(res); | |
}); // piping the stdout (the output from the mysqldump command, in this case the ls command) to the response object | |
// using fs | |
const fs = require('fs'); | |
app.use('/old/bump', (req, res) => { | |
const fileStream = fs.createReadStream('path_to_dump.sql'); | |
fileStream.pipe(res); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment