require('dotenv').config() const express = require('express') const luxon = require('luxon'); const { WebUntis } = require('webuntis'); const app = express() const port = process.env.PORT || 3000 app.get('/', (req, res) => { res.send('server is running') }) app.get('/timetable', async (req, res) => { const untis = new WebUntis(process.env.WEBUNTIS_SCHOOL, process.env.WEBUNTIS_USER, process.env.WEBUNTIS_PASS, process.env.WEBUNTIS_URL); try { await untis.login(); // Start und Ende der aktuellen Woche bestimmen const now = luxon.DateTime.local(); const startOfWeek = now.startOf('week').toJSDate(); // Montag const endOfWeek = now.endOf('week').plus({ days: 7 * 4 * 4 }).toJSDate(); // Sonntag // Stundenplan für diese Woche abrufen const timetable = await untis.getOwnTimetableForRange(startOfWeek, endOfWeek); await untis.logout(); res.json({ status: 'success', data: timetable }); } catch (error) { console.log(error); res.statusCode = 500; res.json({ status: 'error', message: error.message || error.toString() }); } }) const os = require('os'); const nets = os.networkInterfaces(); const results = {}; for (const name of Object.keys(nets)) { for (const net of nets[name]) { if (!net.internal) { results[name] = results[name] || []; results[name].push(net.address); } } } console.log('Local IPs:', results); app.listen(port, () => { console.log(`Example app listening on port ${port}`) })