加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
Guanngxu 提交于 2022-08-17 13:16 . feat: change avtor and id_card img
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")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化