javascript - 使用 express/node.js 启动服务器时出错。跟随 The Coding Train YouTube 教程
问题描述
这个网站上还有其他一些类似的问题,但没有一个可以具体帮助我。
这是我正在关注的视频的链接2.1 Server-side with Node.js - Working with Data and APIs in JavaScript
在视频中的 15:17,我得到了错误
1. GET http://localhost:3000/ 404(未找到)
2.拒绝加载图像“http://localhost:3000/favicon.ico”,因为它违反了以下内容安全策略指令:“default-src 'none'”。请注意,'img-src' 没有显式设置,因此 'default-src' 用作后备。
信用:“编码火车”
下面的javascript
/// index.js ///
const express = require('express');
const app = express();
app.listen(3000, () => console.log('listening at 3000'));
app.use(express.static('public'));
html 下面,在一个名为public的文件夹中
/// tutorial_2_1.html ///
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<h1>Data Selfie App</h1>
<p>Hello?</p>
</body>
</html>
node_modules 文件夹也在我的目录中。
这是我的第一个问题,任何建议将不胜感激。