23 Dec, 2024

Introduction to Angular

Angular.js is an open source JavaScript MVC framework developed by Google. Angular.js is an allows to separate presentation logic and application logic on web applications. HTML is generally use for static documents, What happen when we try to use HTML for dynamic views? Is this possible in web-applications? AngularJS is make that possible dynamic HTML […]

Share your Love
1 min read

How to display image with javascript?

You could make use of the Javascript DOM API. In particular, look at the createElement() method. You could create a re-usable function that will create an image like so… function show_image(src, width, height, alt) { var img = document.createElement(“img”); img.src = src; img.width = width; img.height = height; img.alt = alt; // This next line […]

Share your Love
1 min read

Read file in Node.js

Asynchronously reads the entire contents of a file. var fs = require(‘fs’); var path = require(‘path’); exports.testDir = path.dirname(__filename); exports.fixturesDir = path.join(exports.testDir, ‘fixtures’); exports.libDir = path.join(exports.testDir, ‘../lib’); exports.tmpDir = path.join(exports.testDir, ‘tmp’); exports.PORT = +process.env.NODE_COMMON_PORT || 12346; // Read File fs.readFile(exports.tmpDir+’/world.csv’, ‘utf-8’, function(err, content) { if (err) { got_error = true; } else { console.log(‘cat returned […]

Share your Love
1 min read

Node.js Response.WriteHead function

Up until now all we’ve been sending into the writeHead function is the status code. However, it can take additional parameters like ‘Content-Length’, ‘Content-Type’. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200, {‘Content-Type’: ‘text/html’} ); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080);

Share your Love
1 min read

Node.js Read File from Server

Now, showing you how to create an HTTP non-blocking server and how to read a file of the non-blocking filesystem. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080); Generate Request curl http://localhost:8080

Share your Love
1 min read