HLJ 发布于
2022-11-10 21:34:35

nodejs fs.readFileSync读取txt文件内容

const http = require('http');
const fs = require('fs');
http.createServer(function (req, res) {

    (async () => {
        const file = fs.readFileSync('log.txt');
        console.log(file.toString())
    })();

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.write('Node.js says hello!');
    res.end();
}).listen(8080);
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2022-11-10/617.html
最后生成于 2022-11-21 22:22:39