Skip to content

Instantly share code, notes, and snippets.

@psahni
Created February 19, 2025 08:35
Show Gist options
  • Save psahni/9dcebc2387eece72ccc5d5d4f7578462 to your computer and use it in GitHub Desktop.
Save psahni/9dcebc2387eece72ccc5d5d4f7578462 to your computer and use it in GitHub Desktop.
simple express server
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