Csaba Kissi
Csaba Kissi

@csaba_kissi

8 Tweets 2 reads Dec 11, 2022
How to create a simple Express server in Nodejs πŸ‘‡
First, you will need to create a project folder and then install the Express library.
To do this, open a terminal window and type:
npm install express --save
Once installed, create a file called index.js in your project folder.
This is where you'll write the code for your server.
In the index.js file, add the following code to import the Express library and start the server:
const express = require('express');
const app = express();
//create a route handler
app.get('/', (req, res) => {
res.send('Hello World!')
})
const port = 3000;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Finally, run your server by typing the following command in the terminal:
node index.js
Your server should now be running on port 3000.
Open your browser and open this URL: http://localhost:3000
You should see: Hello World!
Congrats! You created your first Express app.
If you like this post, you can bookmark and tag it by replying with @SaveToBookmarks #nodejs #express
You can view your bookmarks on savetobookmarks.com
That's all, guys.
If you found this list useful, consider:
βœ… Follow @csaba_kissi for more content like this
πŸ”” Enable notifications πŸ‘€
πŸ”„ Retweeting the first tweet.
Thanks for your support, guys! πŸ™πŸ€

Loading suggestions...