DEV Community

Cover image for Creating a simple express server in node
Edwin
Edwin

Posted on • Updated on

Creating a simple express server in node

Using express web framework to create a simple server.

Express is a lightweight web framework for developing web apps
using javascript's runtime environment,node.

Here,I will show you how to create a simple server with express.
First we will install express using npm.

npm i --save express

Now we create the server.

//import the express module
const express = require("express");
const app = express();

//set the port number to listen on
app.set('port',process.env.PORT || 8080);

//create a callback for listening on the server 
app.listen('port',()=>{
    console.log(`Listening on port ${app.get('port')}.Press CTRL Z to cancel.`);
}):
Enter fullscreen mode Exit fullscreen mode

In the next post,I will show you how to set up a templating engine
to handle your layout pages.

Have bug-free day!

Top comments (0)