Skip to content

backend-master/getting-started-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started Express

Express is a NodeJs framework. NodeJs is an amazing tool for building networking services and applications. Its Open Source, Free, easy to extend, very performant.

Installation

Make your project folder and jump to that folder. You can use npm init or yarn init

After that install Express using npm :

npm instal express --save

or using yarn :

yarn add express

The simple directory tree is like this :

.
+-- app.js
+-- package.json
+-- yarn.lock
+-- README.md

Usage

We will make our Express Web Server

here is some code :

const express = require("express"); // Import express library
const app = express(); // Initialize app as express application
const PORT = 3000; // define port to running express app

// Tell to express to listen for a GET request using ".get()" method
app.get("/", (req, res) => {
  res.status(200).json({
    message: "Hello World !"
  });
});

// Set express app to listen at PORT:3000
app.listen(PORT, () => {
  console.log(`Server running on http://localhost:${PORT}`);
});

and then try to run :

node app.js

About

Simple way to learn Express

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published