Skip to content

Commit b098cd9

Browse files
committed
Mal wieder rollback
1 parent 4dbeb3f commit b098cd9

3 files changed

Lines changed: 22 additions & 160 deletions

File tree

app.js

Lines changed: 14 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,33 @@
11
// VATSIM PMP - Simple Express Server
22
const express = require('express')
33
const path = require('path')
4-
const fs = require('fs')
54

65
const app = express()
76

87
// Statische Dateien aus public/ servieren
98
app.use(express.static(path.join(__dirname, 'public')))
109

11-
// Helper to inject header/footer into a page
12-
function renderWithLayout(pagePath, res) {
13-
try {
14-
// Use path.resolve to ensure absolute paths
15-
const headerPath = path.resolve(__dirname, 'public', 'header.html');
16-
const footerPath = path.resolve(__dirname, 'public', 'footer.html');
17-
const contentPath = path.resolve(pagePath);
18-
19-
// Check if files exist
20-
if (!fs.existsSync(headerPath)) {
21-
console.error(`Header file not found: ${headerPath}`);
22-
return res.status(500).send('Server Error: Header template missing');
23-
}
24-
25-
if (!fs.existsSync(footerPath)) {
26-
console.error(`Footer file not found: ${footerPath}`);
27-
return res.status(500).send('Server Error: Footer template missing');
28-
}
29-
30-
if (!fs.existsSync(contentPath)) {
31-
console.error(`Content file not found: ${contentPath}`);
32-
return res.status(404).sendFile(path.join(__dirname, 'public', '404.html'));
33-
}
34-
35-
// Read files with error handling
36-
const header = fs.readFileSync(headerPath, 'utf8');
37-
const footer = fs.readFileSync(footerPath, 'utf8');
38-
let page = fs.readFileSync(contentPath, 'utf8');
39-
40-
// Replace placeholders
41-
page = page.replace('<!--#HEADER-->', header).replace('<!--#FOOTER-->', footer);
42-
43-
// Send the response
44-
res.send(page);
45-
46-
} catch (error) {
47-
console.error('Error in renderWithLayout:', error);
48-
res.status(500).send('Server Error: Failed to render page');
49-
}
50-
}
51-
52-
// Serve header and footer as partials
53-
app.get('/header.html', (req, res) => {
54-
res.sendFile(path.join(__dirname, 'public', 'header.html'))
55-
})
56-
app.get('/footer.html', (req, res) => {
57-
res.sendFile(path.join(__dirname, 'public', 'footer.html'))
58-
})
59-
60-
// Image routes for back1-9
61-
app.get('/back1', (req, res) => {
62-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '1.png'))
63-
})
64-
65-
app.get('/back2', (req, res) => {
66-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '2.png'))
67-
})
68-
69-
app.get('/back3', (req, res) => {
70-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '3.png'))
71-
})
72-
73-
app.get('/back4', (req, res) => {
74-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '4.png'))
75-
})
76-
77-
app.get('/back5', (req, res) => {
78-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '5.png'))
79-
})
80-
81-
app.get('/back6', (req, res) => {
82-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '6.png'))
83-
})
84-
85-
app.get('/back7', (req, res) => {
86-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '7.png'))
87-
})
88-
89-
app.get('/back8', (req, res) => {
90-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '8.png'))
91-
})
92-
93-
app.get('/back9', (req, res) => {
94-
res.sendFile(path.join(__dirname, 'public', 'assets', 'img', '9.png'))
95-
})
96-
9710
// Route für die Hauptseite
9811
app.get('/', (req, res) => {
99-
renderWithLayout(path.join(__dirname, 'public', 'index.html'), res)
12+
res.sendFile(path.join(__dirname, 'public', 'index.html'))
10013
})
10114

10215
// Route für Teilnahme
10316
app.get('/teilnahme', (req, res) => {
104-
renderWithLayout(path.join(__dirname, 'public', 'teilnahme.html'), res)
17+
res.sendFile(path.join(__dirname, 'public', 'teilnahme.html'))
10518
})
10619

10720
// Route für Events
10821
app.get('/events', (req, res) => {
109-
renderWithLayout(path.join(__dirname, 'public', 'events.html'), res)
22+
res.sendFile(path.join(__dirname, 'public', 'events.html'))
11023
})
11124

11225
// Route für Kontakt
11326
app.get('/kontakt', (req, res) => {
114-
renderWithLayout(path.join(__dirname, 'public', 'kontakt.html'), res)
27+
res.sendFile(path.join(__dirname, 'public', 'kontakt.html'))
11528
})
116-
117-
// Route für Anleitung
11829
app.get('/howto', (req, res) => {
119-
renderWithLayout(path.join(__dirname, 'public', 'howto.html'), res)
30+
res.sendFile(path.join(__dirname, 'public', 'howto.html'))
12031
})
12132

12233
// Route für Status
@@ -132,40 +43,19 @@ app.get('/status', (req, res) => {
13243
app.get('/teilnahme.html', (req, res) => res.redirect('/teilnahme'))
13344
app.get('/events.html', (req, res) => res.redirect('/events'))
13445
app.get('/kontakt.html', (req, res) => res.redirect('/kontakt'))
135-
app.get('/howto.html', (req, res) => res.redirect('/howto'))
13646

137-
// Error handling for static files
138-
app.use((err, req, res, next) => {
139-
console.error('Express error:', err);
140-
res.status(500).send('Server Error');
141-
});
142-
143-
// 404 Handler - make sure this is the last middleware
47+
// 404 Handler
14448
app.use((req, res) => {
145-
console.log(`404 Not Found: ${req.originalUrl}`);
146-
res.status(404).sendFile(path.join(__dirname, 'public', '404.html'));
49+
res.status(404).sendFile(path.join(__dirname, 'public', '404.html'))
14750
})
14851

149-
// Better error handling for uncaught exceptions
150-
process.on('uncaughtException', (err) => {
151-
console.error('Uncaught exception:', err);
152-
// Don't exit the process, just log the error
153-
});
154-
155-
// Better error handling for unhandled promise rejections
156-
process.on('unhandledRejection', (reason, promise) => {
157-
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
158-
// Don't exit the process, just log the error
159-
});
52+
// Export für Passenger
53+
module.exports = app
16054

161-
// Export for Passenger
162-
module.exports = app;
163-
164-
// Start Server when directly executed
55+
// Start Server wenn direkt ausgeführt
16556
if (require.main === module) {
166-
const port = process.env.PORT || 80;
57+
const port = process.env.PORT || 80
16758
app.listen(port, () => {
168-
console.log(`VATSIM PMP running on port ${port}`);
169-
});
170-
}
171-
59+
console.log(`VATSIM PMP running on port ${port}`)
60+
})
61+
}

public/teilnahme.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
<h1>Piloten-Mentoren-Programm</h1>
4141
<div class="background">
4242
<div class="slider-container">
43-
<img src="/back1" alt="Aircraft Background" class="slider-image">
44-
<img src="/back2" alt="Aircraft Background" class="slider-image">
45-
<img src="/back3" alt="Aircraft Background" class="slider-image">
46-
<img src="/back5" alt="Aircraft Background" class="slider-image">
47-
<img src="/back6" alt="Aircraft Background" class="slider-image">
48-
<img src="/back7" alt="Aircraft Background" class="slider-image">
49-
<img src="/back8" alt="Aircraft Background" class="slider-image">
50-
<img src="/back9" alt="Aircraft Background" class="slider-image">
43+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/1.png" alt="Aircraft Background" class="slider-image">
44+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/2.png" alt="Aircraft Background" class="slider-image">
45+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/3.png" alt="Aircraft Background" class="slider-image">
46+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/5.png" alt="Aircraft Background" class="slider-image">
47+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/6.png" alt="Aircraft Background" class="slider-image">
48+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/7.png" alt="Aircraft Background" class="slider-image">
49+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/8.png" alt="Aircraft Background" class="slider-image">
50+
<img src="https://cdn.pmp.hosting201623.ae912.netcup.net/9.png" alt="Aircraft Background" class="slider-image">
5151
</div>
5252
</div>
5353
</div>

tsconfig.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)