代码拉取完成,页面将自动刷新
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')
console.log({
...response.data
});
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")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。