Untitled
unknown
plain_text
2 years ago
1.0 kB
5
Indexable
const express = require('express'); const expressApp = require('./app.js'); const path = require('path'); const fs = require('fs'); // const { PORT } = require('./config'); // const expressApp = require('./express-app'); // dotenv.config(); const PORT = process.env.PORT || 6000; const StartServer = async () => { const app = express(); await expressApp(app); app.get('/', async (req, res) => { const filePath = path.join(__dirname, 'index.html'); // Read the content of index.html fs.readFile(filePath, 'utf8', (err, html) => { if (err) { console.error('Error reading HTML file: ', err); return res.status(500).send('Internal Server Error'); } res.send(html); }); }); app.listen(PORT, () => { console.log(`listening to port ${PORT}`); }).on('error', err => { console.error('Error: ', err); process.exit(1); }); }; StartServer();
Editor is loading...