Skip to main content

Posts

Showing posts from January 16, 2019

UUID Lua

UUID Lua In this post, we will write a UUID generator in lua programming language. local function getUUID() local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' return string.gsub(template, '[xy]', function (c) local v = (c == 'x') and random(0, 0xf) or random(8, 0xb) return string.format('%x', v) end) end Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Node.js HTTP Module

Node.js HTTP Module In this tutorial, we will learn about Node.js HTTP module and understand how out code working that we have written in  Getting started with node.js . Node.js has a built-in module called HTTP, which allows Node.js to transfer data over the http. To include the HTTP module, use the require() function. var http = require('http'); Node.js as a Web Server The HTTP module can create an HTTP server that listens to server ports and gives a response back to the client. we used createServer() method to create an HTTP server. var http = require('http'); //create a server object: http.createServer(function (req, res) { res.write('Hello World!'); //write a response to the client res.end(); //end the response }).listen(3000); //the server object listens on port 3000 Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Node.js Module

Node.js Module In this tutorial, we will learn about Node.js module. Node.js Module You can consider Node.js module as java script library which has a set of function that you want to include in your application.  Built-in Modules Node.js has a set of build-in that you can include in your application with any further installation like http .  Node.js  Include Modules To include Node.js module we used require() function with parameter module name. var http = require('http'); Now our application can use method which is in http module. const http = require('http'); const hostname = '127.0.0.1'; const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); C...

Getting started with Node.js

Getting started with Node.js In this tutorial, We will create first Node.js application that simply return Hello, World! to the client. Create App in Node.js  Once you have installed Node, create a file named app.js, and paste the following code.  const http = require('http'); const hostname = '127.0.0.1'; const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); Run Node.js App Navigate to the folder which contain app.js file and run following command on terminal. node app.js Open your favourite browser and search http://127.0.0.1:3000 Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above...

Install Node.js

Install NodeJs In this tutorial, We will learn how to install Node.js on Ubuntu. Install Node.js v10.x # Using Ubuntu curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - sudo apt-get install -y nodejs Source :  Node Js Distribution Github Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.