Web Server

Web Server In Node.js1 min read

Hey Programmers, Welcome to the Another JavaScript Project, In this Blog We Will Be Creating a Web Sever Using Node.js. If you Don’t Know What is Node.js Then In Simple Words Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser, which was designed to build scalable network applications.

Also Read:

• Realtime Chat Application Socket.io

• Email Automation Using Python

• Password Validation Using JavaScript

For Creating this Project You Need to Install Node.js In Your Computer.

What Is Web Server?

A Web Server is a Server Which Accepts Requests Via HTTP (Hyper Text Transfer Protocol) Or Secure Version HTTPS Text Transfer Protocol Secure)

This Web Server Runs In your Local System It Uses a Port Called Port 3000.

Server.Js File

const http = require('http')
const port = 3000

const server = http.createServer(function(req ,res){
    res.write('Web Server In Node.js')
    res.end()
})

server.listen(port, function(error) {
    if (error) {
        console.log('Something Went Wrong', error)
    }
    else{
        console.log('Sever Started Sucessfully', + port)
    }
})

So This Was It For Todays Blog See You In the Next One Till Then Keep Coding Keep Exploring!

DOWNLOAD SOURCE CODE

Tanmay Sinha

Author

  • Tanmay Sinha

    Founder & CEO of MrProgrammer.in | I help Learning Freaks to Step into the World of Programming and Our Mission is to Provide High Quality and Valuable Content to Our Users! We believe that everyone has the potential to learn to code, and we are committed to making that happen. Our courses are designed to be engaging and interactive, and we offer a variety of learning paths to meet the needs of all learners. We are also committed to providing our learners with the support they need to succeed, and we offer a variety of resources to help learners learn at their own pace. If you are interested in learning to code, we encourage you to check out our courses. We are confident that you will find our content to be high-quality, valuable, and makes sense.