const express = require('express'); const getSuggestedEndpoint = require('./endpoint_handlers/suggested.js'); const getMetadataEndpoint = require('./endpoint_handlers/metadata.js'); const getOccasionsEndpoint = require('./endpoint_handlers/occasions.js'); const getLicenceInfo = require('./endpoint_handlers/licenseinfo.js'); // Read the port from the environment if possible const port = process.env.PORT || 3000; const server = express(); // Set up the static directory to server cssa and other assets server.use('/static', express.static('static')); server.use(express.json()); server.use( express.urlencoded({ extended: true, }) ); // Root path serves index server.get('/', (req, res) => { res.sendFile(__dirname + '/html/index.html'); }); // Set up API endpoints server.post('/suggested', getSuggestedEndpoint) server.post('/metadata', getMetadataEndpoint) server.post('/occasions', getOccasionsEndpoint) server.post('/licenseinfo', getLicenceInfo) // Listen and provide feedback server.listen(port, () => { console.log(`Server running on http://localhost:${port}`); });