-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (29 loc) · 1.03 KB
/
app.js
File metadata and controls
37 lines (29 loc) · 1.03 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
const express = require('express');
const path = require('path');
const app = express();
// Serve static files from the 'public' directory
app.use(express.static(path.join(__dirname, 'public')));
// Parse form data
app.use(express.urlencoded({ extended: true }));
// Route for serving the authentication page
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Route for handling authentication form submission
app.post('/dashboard', (req, res) => {
const { username, password } = req.body;
// Replace with your authentication logic
if (username === 'badgeadmin' && password === 'badgeadmin') {
res.sendFile(path.join(__dirname, 'public', 'dashboard.html'));
} else {
res.send('Authentication failed');
}
});
// Route for serving the badge printing page
app.get('/badgingapp', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Start the server
app.listen(3001, () => {
console.log('Badging App is running on port 3001');
});