node.js - 本地主机不会打开(Node.js 服务器)
问题描述
我在 node.js 中为我的项目创建了一个服务器,但 localhost 无法打开。
服务器显然可以工作,但是当我输入 http://localhost:8080 / 页面正在加载并且无法打开。
我正在为服务器使用快递。
我一直试图解决它几个小时,但我找不到任何东西来解决它。
项目文件夹是 \wsl$\Ubuntu\home\fplp\projects\Node-js-projects。
我在适用于 Linux 的 Windows 子系统中有 Ubuntu 20.04 LTS
接下来我将展示服务器的代码和终端页面的照片。
//这是server.js文件\
const express = require('express');
const app = express();
app.set("view engine", "ejs");
app.get("/", function (req, res){
res.render("index");
})
app.get("/about", function (req, res){
res.render("about");
})
app.listen(8080);
console.log("Server is Online");
//终端照片(wsl)。
解决方案
推荐阅读
- python - 如何使用 __pycache__ 文件夹运行 Python 项目?
- java - Java 8 使用流重写复杂的 for 循环
- javascript - 如何使用单个函数在画布上绘制多个图像?
- c++ - GLib-GObject-CRITICAL ...断言“夸克> 0”失败
- python - 使用 set() 或 {} 创建集合的区别
- android-studio - Android Studio - Flutter Plugin - 通过重构将方法移动到另一个文件
- javascript - 如何将单行数组转换为多行数组?
- ios - 我的 Firebase 观察者不会停止观察
- php - 如何创建价格变化模块 | PrestaShop
- scala - Scala如何订阅多个kafka主题