Express - 静态网页模板(三)

2019-04-16  本文已影响0人  w_wx_x

文章推荐

Express-官方文档
Express-菜鸟教程
阮一峰博客-Express
案例代码github

文件目录.png
// app.js
var express = require('express');
var app = express();

app.get('/',function(req,res){
    res.sendFile(__dirname + '/views/index.html')
})
app.get('/about',function(req,res){
    res.sendFile(__dirname + '/views/about.html')
})
app.get('/article',function(req,res){
    res.sendFile(__dirname + '/views/article.html')
})

app.listen(3000)
<!-- index.html -->
<html>
<head>
    <title>静态网页模板</title>
</head>
<body>
    <h1>首页</h1>
    <footer>
        <p>
            <a href="/about">自我介绍</a> - <a href="/article">文章</a>
        </p>
    </footer>
</body>
</html>
<!-- about.html -->
<html>
<head>
   <title>静态网页模板</title>
</head>
<body>
<h1>自我介绍</h1>
<footer>
<p>
   <a href="/">首页</a>  - <a href="/article">文章</a>
</p>
</footer>
</body>
</html>
<!-- article.html -->
<html>
<head>
    <title>静态网页模板</title>
</head>
<body>
    <h1>文章</h1>
    <footer>
        <p>
            <a href="/">首页</a> - <a href="/about">自我介绍</a> 
        </p>
    </footer>
</body>
</html>
node app.js      // 启动
首页.png
上一篇 下一篇

猜你喜欢

热点阅读