Created
September 27, 2020 02:28
-
-
Save kuc-arc-f/dd8dfe8b6209dbfb3928907baf9f0aaa to your computer and use it in GitHub Desktop.
expressで Rust プロセス起動、jsonファイルから sqlite3登録
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
// expressで Rust プロセス起動、jsonファイルから sqlite3登録 | |
var express = require('express'); | |
var router = express.Router(); | |
const { performance } = require('perf_hooks'); | |
const { spawn } = require('child_process'); | |
// | |
router.get('/', function(req, res, next) { | |
res.send('respond with a resource-1234'); | |
}); | |
// | |
router.get('/test1', function(req, res, next) { | |
// console.log("test_proc"); | |
var json_fname = "/home/naka/work/node/express/app7/public/tasks.json"; | |
var dbfname = "/home/naka/work/node/express/app7/public/test.db"; | |
const child = spawn('./public/sqlite-test', [json_fname , dbfname ]); | |
child.stdout.on('data', (data) => { | |
console.log('stdout data:', data.toString('utf8')); | |
}); | |
child.stderr.on('data', (data) => { | |
console.error('stderr data:', data.toString('utf8')); | |
}); | |
child.on('close', (code) => { | |
console.log("on close:", code); | |
}); | |
res.send("1"); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment