-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (50 loc) · 1.4 KB
/
index.js
File metadata and controls
65 lines (50 loc) · 1.4 KB
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
56
57
58
59
60
61
62
63
64
65
import express from "express";
import bodyParser from "body-parser";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import path from 'path';
import dotenv from 'dotenv';
dotenv.config();
const app = express();
const port = process.env.PORT || 3000;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Set view engine and views folder
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// Serve static files from /public
app.use(express.static(path.join(__dirname, 'public')));
// Body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Routes
app.get("/", (req, res) => {
res.render('index');
});
app.get("/connect", (req, res) => {
res.render('connect');
});
app.get("/achievement", (req, res) => {
res.render('achievement');
});
app.get("/projects", (req, res) => {
res.render('projects');
});
app.get("/education", (req, res) => {
res.render('education');
});
app.get("/header", (req, res) => {
res.render('partials/header');
});
app.get("/footer", (req, res) => {
res.render('partials/footer');
});
app.get('/contact', (req, res) => {
res.render('contact', {
WebappURL: process.env.WebappURL || 'https://your-vercel-site.vercel.app'
});
});
// Start the server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});