最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

如何在Node.js中正确设置路由器

IT培训 admin 16浏览 0评论

如何在Node.js中正确设置路由器

当我通过Express运行服务器时,发现了如下所述的错误。

当我访问下面的网址时,

显示以下错误。

The file '/login_form/views/login' could not be found. Are you sure it is in your environment?

我当前的工作如下,

有什么奇怪的地方吗?

谢谢

login_form/views $ ls
login.html  main.css  signup.html
const express = require("express");
const app = express();

app.get('/login', (req, res) => {
  res.render('login.html');
});

app.get('/signup', (req, res) => {
  res.render('signup.html');
});



app.listen(3000,()=>{
    console.log('server is running!');
});
回答如下:

[当您尝试访问页面时,您正在使用系统上的文件路径。您实际上需要的是服务器的网址:

http://localhost:3000(确保您之前已启动节点服务器)

欢呼!

如何在Node.js中正确设置路由器

当我通过Express运行服务器时,发现了如下所述的错误。

当我访问下面的网址时,

显示以下错误。

The file '/login_form/views/login' could not be found. Are you sure it is in your environment?

我当前的工作如下,

有什么奇怪的地方吗?

谢谢

login_form/views $ ls
login.html  main.css  signup.html
const express = require("express");
const app = express();

app.get('/login', (req, res) => {
  res.render('login.html');
});

app.get('/signup', (req, res) => {
  res.render('signup.html');
});



app.listen(3000,()=>{
    console.log('server is running!');
});
回答如下:

[当您尝试访问页面时,您正在使用系统上的文件路径。您实际上需要的是服务器的网址:

http://localhost:3000(确保您之前已启动节点服务器)

欢呼!

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论