作者:thofarq | 来源:互联网 | 2023-08-25 17:05
web前端|js教程nodejs,路由功能web前端-js教程本篇文章给大家介绍一下使用Node实现较复杂应用路由功能的方法最新千月影视双端完美运营版源码,ubuntudeb官网,
web前端|js教程
nodejs,路由功能
web前端-js教程
本篇文章给大家介绍一下使用Node实现较复杂应用路由功能的方法
最新千月影视双端完美运营版源码,ubuntu deb官网,网络爬虫结果抓取,seafile php,wap优化seolzw
一键采集视频网站源码,ubuntu 重启原理,本机的tomcat无法启动,爬虫框架淘宝,php中form表单提交,沙坪坝区操作简便seo推广lzw
《nodejs 教学》
fm电台源码,如何在vscode上运行c,ubuntu 显卡 崩溃,tomcat去除版本信息,爬虫 豆瓣影评,php welive,广州seo关键词优化品牌lzw
结构
项目结构如下
代码如下
功能
【router.js】
// 加载所需模块var http = require('http');var url = require('url');var fs = require('fs');var host = '127.0.0.1';var port = 8080;http.createServer(function(req,res){ var pathname = url.parse(req.url).pathname; console.log('Request for ' + pathname + ' received.'); function showPaper(path,status){ var cOntent= fs.readFileSync(path); res.writeHead(status, { 'Content-Type': 'text/html;charset=utf-8' }); res.write(content); res.end(); } switch(pathname){ //'首页' case '/': case '/home': showPaper('./view/home.html',200); break; //'about页' case '/about': showPaper('./view/about.html',200); break; //'404页' default: showPaper('./view/404.html',404); break; } }).listen(port, host);
【404.html】
404
【about.html】
about
【home.html】
home
演示
编程视频!!