An open API service indexing awesome lists of open source software.

https://github.com/survi218/node-modules

Node and the HTTP Module
https://github.com/survi218/node-modules

callback-functions error-handler get node-http node-module nodejs npm post postman requirejs server-core

Last synced: about 2 months ago
JSON representation

Node and the HTTP Module

Awesome Lists containing this project

README

        

# node-modules
#Node modules:
- HTTP, fs and path. At the end of this exercise, you will be able to:
- Implement a simple HTTP Server
- Implement a server that returns html files from a folder
* A Simple HTTP Server
- Create a folder named node-http at a convenient location and move into the folder.
- In the node-http folder, create a subfolder named public.
- Create a file named server-1.js and add the following code to it:

````
var http = require('http');

var hostname = 'localhost';
var port = 3000;

var server = http.createServer(function(req, res){
console.log(req.headers);
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('

Hello World

');
})
server.listen(port, hostname, function(){
console.log(`Server running at http://${hostname}:${port}/`);
});
````