Skip to content

Instantly share code, notes, and snippets.

@prashantsani
Created March 6, 2024 15:11
Show Gist options
  • Save prashantsani/549b5eb7b3820c78ce00b847290cdd19 to your computer and use it in GitHub Desktop.
Save prashantsani/549b5eb7b3820c78ce00b847290cdd19 to your computer and use it in GitHub Desktop.
Basic Node Server
/* Prompts */
// npm init -y
// npm install express
// touch index.js
/// ------------------------
// Contents of `index.js` file
import express from "express";
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Welcome to my server!');
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
/// ------------------------
// Prompt to run above file
// node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment