Created
February 19, 2025 08:35
-
-
Save psahni/9dcebc2387eece72ccc5d5d4f7578462 to your computer and use it in GitHub Desktop.
simple express server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const path = require('path'); | |
const app = express(); | |
// Serve static files from the root directory | |
app.use(express.static(__dirname)); | |
// Serve the index.html file | |
app.get('/', (req, res) => { | |
res.sendFile(path.join(__dirname, 'index.html')); | |
}); | |
const PORT = 4000; | |
app.listen(PORT, () => { | |
console.log(`Server is running on http://localhost:${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment