const express = require('express'); const Thermal = require('./modules/Thermal.js'); const app = express(); const port = 80; // Middleware to serve static files (HTML) app.use(express.static('public')); // Middleware to parse JSON request bodies app.use(express.json()); // Test print function app.post('/print', async (req, res) => { try { const { username, studentId } = req.body; if (!username || !studentId) { return res.status(400).json({ message: 'Username and Student ID are required.' }); } await Thermal.printCredentials(username, studentId, req, res); } catch (error) { console.error('Print Error:', error); res.status(500).json({ message: 'Print Error', error: error.message }); } }); // Start the server app.listen(port, () => { console.log(`Server running at http://localhost:${port}`); });