当前位置:网站首页>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')
})
边栏推荐
猜你喜欢
Understand what MySQL index push down (ICP) is in one article

Four Misunderstandings of Internet Marketing

Adobe Photoshop (PS) - script development - remove file bloated script

Phoenix architecture: an architect's perspective

本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置

Clickhouse native monitoring item, system table description

文本生成模型退化怎麼辦?SimCTG 告訴你答案

雷达数据处理技术

1-2 安装并配置MySQL相关的软件

AKK菌——下一代有益菌
随机推荐
“信任机器”为发展赋能
Random talk about Clickhouse join
物联网僵尸网络Gafgyt家族与物联网设备后门漏洞利用
Clickhouse Native Monitoring item, System table Description
科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?
Apply for vector bus protocol color picture wallpaper hanging picture, very good!
Side sleep ha ha ha
本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置
兴奋神经递质——谷氨酸与大脑健康
1-15 nodemon
给苏丹国安德森苏丹的撒过 d s g
测试媒资缓存问题
Ssh server configuration file parameter permitrootlogin introduction
Internet of things botnet gafgyt family and backdoor vulnerability exploitation of Internet of things devices
3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
pytorch geometric torch-scatter和torch-sparse安装报错问题解决
Learning summary
的撒啊苏丹看老司机
根据肠道微生物组重新思考健康饮食
测试勋章1234