forked from rleai/rleai.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (23 loc) · 694 Bytes
/
server.js
File metadata and controls
29 lines (23 loc) · 694 Bytes
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
require('dotenv').config();
const express = require('express');
const path = require('path');
const authRouter = require('./_auth/github');
const profileRouter = require('./_auth/profile');
const app = express();
const PORT = process.env.PORT || 4000;
// 中间件
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// 静态文件服务
app.use(express.static(path.join(__dirname, '_site')));
// 认证路由
app.use(authRouter);
app.use(profileRouter);
// 主页路由
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '_site', 'index.html'));
});
// 启动服务器
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});