当前位置:网站首页>1-11 create online file service
1-11 create online file service
2022-06-30 21:29:00 【Endless pie】
Create an online file service
const http = require('http')
// establish web The server
const server = http.createServer()
// monitor web The server request event
server.on('request', (req, res) => {
const url = req.url
// Request url Address , Mapped to the storage path of local files
// const fpath = path.join(__dirname, url)
let fpath = ''
if (url == '/') {
fpath = path.join(__dirname, './clock/index1.html')
} else {
fpath = path.join(__dirname, './clock', url)
}
fs.readFile(fpath, 'utf-8', function(err, data) {
if (err) return res.end('404 not found')
res.end(data)
})
})
// Start the server
server.listen(80, () => {
console.log('server running at http://127.0.0.1')
})
边栏推荐
猜你喜欢

ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
Testing media cache

Prediction and regression of stacking integrated model

Reading notes of Clickhouse principle analysis and Application Practice (2)

AKK菌——下一代有益菌

3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充

Multi table operation - foreign key constraint

Radar data processing technology

申请Vector 总线协议彩图壁纸挂画,非常棒哦!

Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
随机推荐
1-1 数据库的基本概念
Multi table operation - foreign key constraint
根据肠道微生物组重新思考健康饮食
To the Sultanate of Anderson
Encryption and decryption and the application of OpenSSL
WebRTC系列-网络传输之本地scoket端口
文本识别-SVTR论文解读
Is it safe to open an account for stock trading on mobile phones?
1-20 预检请求
科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?
企业保护 API 安全迫在眉睫
文本生成模型退化怎么办?SimCTG 告诉你答案
兴奋神经递质——谷氨酸与大脑健康
ca i啊几次哦啊句iu家哦
Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
. NETCORE redis geo type
Coefficient of variation method matlab code [easy to understand]
興奮神經遞質——穀氨酸與大腦健康
How to run jenkins build, in multiple servers with ssh-key
升级kube出现unknown flag: --network-plugin