-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
54 lines (43 loc) · 1.46 KB
/
app.js
File metadata and controls
54 lines (43 loc) · 1.46 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
// VATSIM PMP - Simple Express Server
const express = require('express')
const path = require('path')
const app = express()
// Statische Dateien aus public/ servieren
app.use(express.static(path.join(__dirname, 'public')))
// Route für die Hauptseite
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'))
})
// Route für Teilnahme
app.get('/teilnahme', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'teilnahme.html'))
})
// Route für Events
app.get('/events', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'events.html'))
})
// Route für Kontakt
app.get('/kontakt', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'kontakt.html'))
})
app.get('/howto', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'howto.html'))
})
// Redirect .html URLs to their route counterparts
app.get('/teilnahme.html', (req, res) => res.redirect('/teilnahme'))
app.get('/events.html', (req, res) => res.redirect('/events'))
app.get('/kontakt.html', (req, res) => res.redirect('/kontakt'))
app.get('/howto.html', (req, res) => res.redirect('/howto'))
// 404 Handler
app.use((req, res) => {
res.status(404).sendFile(path.join(__dirname, 'public', '404.html'))
})
// Export für Passenger
module.exports = app
// Start Server wenn direkt ausgeführt
if (require.main === module) {
const port = process.env.PORT || 80
app.listen(port, () => {
console.log(`VATSIM PMP running on port ${port}`)
})
}