请用Node.js的express写一段网页,html文件和css文件在同一个文件夹‘www’中,而Node.js文件与'www'文件夹在同一目录中。请把Node.js代码,html代码和css代码告诉我
时间: 2023-03-29 11:00:47 浏览: 96
以下是Node.js的express代码:
```javascript
const express = require('express');
const app = express();
app.use(express.static('www'));
app.listen(300, () => {
console.log('Server is running on port 300');
});
```
以下是HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is some text.</p>
</body>
</html>
```
以下是CSS代码:
```css
body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p {
font-family: verdana;
font-size: 20px;
}
```
阅读全文