Ping 127,ping不通的原因已经找到了,是昨天安装了360免费WIFi。。。卸载即可
发布于 8 年前 作者 SHocker-Yu 5544 次浏览 来自 问答

1.png 1.png

代码如下: var express = require(‘express’); var port = process.env.PORT || 4000;//process 是一个全局变量,用来获取环境变量,以及外围我们传入的参数 var app =express(); app.set(‘views’,’./views’);//启动一个web服务器,设置试图的根目录 app.set(‘view engine’,‘jade’);//设置默认的模版引擎 app.listen(port);//监听端口

console.log('web started on port '+ port);//打印一条日志,从控制台看到服务是否启动

//主要页面的路由 app.get(’/’,function (req,res) { res.render(‘index’,{ title:‘FirstWeb 首页’//替换index.jade中的#(占位符) }) ; }); console.log(‘web started on port ‘+ port); // /xx/路径自己定义,别重复 app.get(’/movie/:id’,function (req,res) { res.render(‘detail’,{ title:‘FirstWeb 详情页’ }) ; });

app.get(’/admin/movie’,function (req,res) { res.render(‘admin’,{ title:‘FirstWeb 后台录入页’ }) ; });

app.get(’/admin/list’,function (req,res) { res.render(‘list’,{ title:‘FirstWeb 列表页’ }) ; });

其中index,admin,detail,list代码: doctype html head meta(charset=‘utf-8’) title #{title} body h1 #{title}

之前这个是已经成功运行过了的,所以很纳闷。

我用官方demo测试了,也不行: var http = require(‘http’); http.createServer(function(req,res){ res.writeHead(200,{‘Content-Type’:‘text/plain’}); res.end(‘Hello Nodejs\n’); }).listen(1337,‘127.0.0.1’); console.log(‘Server running at http://127.0.0.1:1337/’);

1.png 2.png

有人知道怎么解决吗?

2 回复

按你贴出的代码跑了下,没有问题的,你自己再check下

@mygoare 早上自己Ping 127,ping不通,然后以为是IP协议出错了,准备重装,再然后。。搜到了一个挂在最底下的回答:360免费wifi会影响XXX,然后想起来我昨天确实刚刚安装了360免费wifi,卸载后,即可。。。。。。

回到顶部