殊途同归
var express=require('express')
var fs=require('fs')
var path=require('path')
var app=express()
app.use(express.static(path.join(__dirname,'public')))
// app.get('/',(req,res)=>{
// res.writeHead(200,{'Content-Type':'text/plain'})
// res.end('hello world')
// })
app.get('/index',(req,res)=>{
fs.readFile('1.txt','utf8',(err,data)=>{
if (err) {console.log(err)}
res.writeHead(200,{'Content-Type':'text/palin'})
res.end(data)
})
})
app.get('/index/html',(req,res)=>{
fs.readFile('aa.html','utf8',(err,data)=>{
if (err) {console.log(err)}
res.writeHead(200,{'Content-Type':'text/html'})
res.end(data)
})
})
var statInfo = fs.statSync('1.txt');
console.log(statInfo);
fs.readdirSync(__dirname).forEach(file=>console.log(file))
//1.txt a aa.html b c node_modules package.json public server.js
fs.readdirSync(__dirname).forEach(file=>{
if (true) {}
})
app.listen(8888)
console.log('server is running at port 8888')
var express=require('express')
var app=express()
app.get('/about',(req,res)=>{
res.sendfile('about.html')
})
app.get('/artical',(req,res)=>{
res.sendfile('artical.html')
})
app.get('/',(req,res)=>{
res.sendfile('index.html')
})
app.listen(8888)
console.log('server is running at port 8888')
You can change the world with your heart,even a lot of changes sometimes unless you won't geiv up....