Test_express / main.js
Sharathhebbar24's picture
Upload 5 files
41a4d53 verified
raw
history blame
472 Bytes
const express = require('express');
const path = require('path');
const app = express();
const PORT = 3000;
// Serve static files from the 'public' directory
app.use(express.static(path.join(__dirname, 'public')));
// Define API endpoints
app.get('/api/message', (req, res) => {
res.json({ message: 'Hello from the backend!' });
});
// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});