-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (46 loc) · 1.49 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express')
const ejs = require('ejs')
const path = require('path')
const axios = require('axios')
const app = express()
app.use(express.static(__dirname))
app.set('views', path.join(__dirname, '/templates'));
app.set('view engine', 'ejs');
/**
* Home Page & Post List Page
*/
app.get('/', async (req, res) => {
const response = await axios.get('https://raw.githubusercontent.com/getgridea/mock-json/master/list.json')
res.render('index', { ...response.data })
})
/**
* Post Page
*/
app.get('/post/:postName', async (req, res) => {
const response = await axios.get('https://raw.githubusercontent.com/getgridea/mock-json/master/post.json')
res.render('post', { ...response.data })
})
/**
* Archives Page
*/
app.get('/archives', async (req, res) => {
const response = await axios.get('https://raw.githubusercontent.com/getgridea/mock-json/master/archives.json')
res.render('archives', { ...response.data })
})
/**
* tags Page
*/
app.get('/tags', async (req, res) => {
const response = await axios.get('https://raw.githubusercontent.com/getgridea/mock-json/master/tags.json')
res.render('tags', { ...response.data })
})
/**
* tag Page
*/
app.get('/tag/:tagName', async (req, res) => {
const response = await axios.get('https://raw.githubusercontent.com/getgridea/mock-json/master/tag.json')
res.render('tag', { ...response.data })
})
//使用8080端口
app.listen(3001)
console.log("The server is running on 3001")