The following code shows Creating a Server in NodeJS.
Here we need to use the ‘http’ module for creating the server. Furthermore, use the createServer() method and specify the function to execute in it. After that call the listen() method and specify the port number.
var server=require('http');
server.createServer(function(request, response){
response.write('https://www.programmingempire.com/: A NodeJS Server');
response.end('A Basic Example of NodeJS Server!');
}).listen(3219);
Output
Now run the following command to start the server.
Once we start the server, we can open the web page at http://localhost:3219/
Further Reading
Understanding NodeJS With Examples
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML