Web Programming Language

Slides:



Advertisements
Similar presentations
Other Web Application Development Technologies. PHP.
Advertisements

Intel Do-It-Yourself Challenge node.js
PHP syntax basics. Personal Home Page This is a Hypertext processor It works on the server side It demands a Web-server to be installed.
© 2014 IBM Corporation Empowering the IBM ecosystem Introduction to Developing applications using node.js on Bluemix IBM Ecosystem Development Instructors.
CSCI 3100 Tutorial 3 JavaScript & Node.js Presented by SU Yuxin Department of Computer Science and Engineering The Chinese University of Hong Kong 1.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
PHP and MySQL Week#1  Course Plan.  Introduction to Dynamic Web Content.  Setting Up Development Server Eng. Mohamed Ahmed Black 1.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Node.js - What is Node.js? -
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
An Introduction to Front-end Web Development Tom Perkins.
SE-2840 Dr. Mark L. Hornick1 NodeJS Server-side JavaScript.
Zz SOCKET.IO going real time with Arnout Kazemier
Chat Room App Logan Linn Network Application Design Fall 2010.
The Module Road Map Assignment 1 Road Map We will look at… Internet / World Wide Web Aspects of their operation The role of clients and servers ASPX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Web Server Content What is web server Web Server working concept ◦ Static document ◦ Dynamic document ◦ Client side Processing Easy.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
How CGI and Java Servlets are Run By David Stein 14 November 2006.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
CGS 3066: Web Programming and Design Spring 2016 Introduction to Server-Side Programming.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Configuring Nodes Application on BlueMix
Profound.js: The future of open source development on IBM i
CGS 3066: Web Programming and Design Spring 2017
NodeJS and MEAN cs6320.
Tonga Institute of Higher Education IT 141: Information Systems
Node.Js Server Side Javascript
Section 6.3 Server-side Scripting
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
The Server-side JavaScript
Node.js Express Web Applications
Working with Client-Side Scripting
CSE 775 – Distributed Objects Submitted by: Arpit Kothari
NodeJS and MEAN Prof. L. Grewe.
3 Things Everyone Knows About Node JS That You Don't
AJAX.
PHP / MySQL Introduction
Node.Js Server Side Javascript
2017, Fall Pusan National University Ki-Joune Li
Client side & Server side scripting
Tonga Institute of Higher Education IT 141: Information Systems
CMPE 280 Web UI Design and Development January 30 Class Meeting
Abel Sanchez, John R. Williams
JavaScript.
Web Socket Server (using node.js)
Tonga Institute of Higher Education IT 141: Information Systems
CMPE 280 Web UI Design and Development January 29 Class Meeting
Web Programming Language
INTRODUCTION TO By Stepan Vardanyan.
Lecture 11: Node.JS February 16, 2018 Open twitter page, sphere-e page
Lecture 12: The Fetch Api and AJAx
Lecture 14: JSON and Web SERVICES
Week 02 Node.js Week 02
Client-Server Model: Requesting a Web Page
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Web Application Development Using PHP
CMPE 280 Web UI Design and Development August 27 Class Meeting
Presentation transcript:

Web Programming Language Chapter 13

Introducing Node.JS PHP vs Node.js Setting Up Node.js Events in Node.js Node Package Manager (NPM) Sending Emails with Node.js

Node vs PHP PHP was created in 1994, so is a well established language for the server Powers around 80% of the web Many applications built using PHP Wordpress, Drupal, Joomla, WooCommerce, Magento, ZenCart, Laravel, Symfony, CodeIgniter, Zend However, Node.js (since 2009) has gained popularity, allowing “JavaScript Everywhere”

Standard PHP Request (Blocking) Send the request to the server file system Wait for the file system to open and read the file Return the content to the client Ready for another request

But, in Node.js (non-blocking) Send the request to the server file system Ready to handle another request When the file system has opened the file, the server sends the content to the client

Setting up Node.js Download and install Node from:- https://nodejs.org/en/

Create a new file called hello.js var http = require('http'); http.createServer(function (req, res) { res.write('Hello World'); res.end(); }).listen(8080);

Node.js Command Prompt Navigate to that file and add the command:- node hello.js

Open Browser And go to localhost:8080

Hello World var http = require('http'); http.createServer(function (req, res) { res.write('Hello World'); res.end(); }).listen(8080); Includes http module Creates a server listening on port 8080

Extending var http = require('http'); Request and Response Objects var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(req.url); res.end(); }).listen(8080); Writes the request URL

Parsing the URL var http = require('http'); var url = require('url'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); var myURL = url.parse(req.url, true); res.write("Pathname: " + myURL.pathname + "<br>"); res.write("Search: " + myURL.search + "<br>"); var myURLData = myURL.query; res.write("Query: " + myURLData.month); res.end(); }).listen(8080);

Events in Node.js var events = require('events'); var eventEmitter = new events.EventEmitter(); var myEventHandler = function () { console.log('Do Something'); } eventEmitter.on('Go', myEventHandler); eventEmitter.emit('Go');

The Node Package Manager (NPM) Thousands of contributed modules to extend Node – Free! https://www.npmjs.com/ For example:- https://www.npmjs.com/package/num2fraction npm install num2fraction

Number to Fraction var http = require('http'); var n2f = require('num2fraction'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(n2f(0.5)); res.end(); }).listen(8080);

Sending Emails? NPM install! var http = require('http’); var nodemailer = require('nodemailer’); var transporter = nodemailer.createTransport({ service: 'gmail’, auth: { user: 'myemail@gmail.com’, pass: 'secretpass’ } }); var mailOptions = { from: 'myemail@gmail.com’, to: ' myfriend@yahoo.com’, subject: 'Welcome to the web’, text: 'Feel free to explore!’ }; transporter.sendMail(mailOptions, function(error, info){ if (error) { console.log(error); } else { console.log('Email sent: ' + info.response); } }); NPM install!

Summary Node.js is a popular, modern server-side runtime environment written in JavaScript, which is fast due to its ability to handle requests without blocking. Node.js can be used to handle Http requests, by creating a server and parsing the requested URL. Node.js can be set up as a file server to return different files depending on the Http request. The emit() method can be used to respond to server-side events, such as when a user enters or leaves a chat room. The Node Package Manager (or NPM) is a large collection of modules of code that are publicly available and easily installed using npm.