Created
March 6, 2024 15:11
-
-
Save prashantsani/549b5eb7b3820c78ce00b847290cdd19 to your computer and use it in GitHub Desktop.
Basic Node 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
/* 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