2017, Fall Pusan National University Ki-Joune Li

Slides:



Advertisements
Similar presentations
1 CGICGI Common Gateway Interface Server-side Programming Lecture.
Advertisements

Internet of Things with Intel Edison Web controller
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.
Multiple Tiers in Action
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
CSE451 Section 6: Spring 2006 Web server & preemption.
E-Commerce The technical side. LAMP Linux Linux Apache Apache MySQL MySQL PHP PHP All Open Source and free packages. Can be installed and run on most.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
PHP and MySQL Week#1  Course Plan.  Introduction to Dynamic Web Content.  Setting Up Development Server Eng. Mohamed Ahmed Black 1.
Intro to PHP Introduction to server-side scripts (It’s all good :D) © TAFE NSW
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
Silverlight 2 has rich networking support SOAP/XML Web services via WCF proxies Untyped HTTP services (REST, RSS, ATOM) via HttpWebRequest and WebClient.
Node.js - What is Node.js? -
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Chat Room App Logan Linn Network Application Design Fall 2010.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
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.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
ASP.NET WEB Applications. ASP.NET  Web application framework developed by Microsoft  Build dynamic data driven web applications and web services  Subset.
1 K. Salah Application Layer Module K. Salah Network layer duties.
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.
PHP using MySQL Database for Web Development (part II)
NodeJS and MEAN cs6320.
Tiny http client and server
Node.Js Server Side Javascript
Physics validation database
Introduction to Dynamic Web Programming
Web Development Web Servers.
Node.js Express Web Applications
Working with Client-Side Scripting
CSE 775 – Distributed Objects Submitted by: Arpit Kothari
AJAX and REST.
NodeJS and MEAN Prof. L. Grewe.
3 Things Everyone Knows About Node JS That You Don't
Introduction Web Environments
Developing Web-Based Applications
Working at a Small-to-Medium Business or ISP – Chapter 7
PHP / MySQL Introduction
Week 03 Node.js Week 03
Working at a Small-to-Medium Business or ISP – Chapter 7
Node.Js Server Side Javascript
Database Driven Websites
Multimedia and Networks
Web Programming Language
Secure Web Programming
INTRODUCTION TO By Stepan Vardanyan.
Intro to PHP.
Lecture 11: Node.JS February 16, 2018 Open twitter page, sphere-e page
Internet Applications & Programming

Lecture 12: The Fetch Api and AJAx
APACHE WEB SERVER.
Lecture 14: JSON and Web SERVICES
PHP an introduction.
Week 02 Node.js Week 02
Client-Server Model: Requesting a Web Page
Web Servers (IIS and Apache)
Web Application Development Using PHP
Presentation transcript:

2017, Fall Pusan National University Ki-Joune Li Node.js 2017, Fall Pusan National University Ki-Joune Li

Server Side Programming Client Side Server Side HTTP request Web Client – Browser (JavaScript) Web Server HTTP response (HTML, CSS, JavaScript, JSON, XML, etc..) ASP.NET, PHP, Node.js, etc..

Basic Concepts Node.js Node.js can A Node.js file operates on uses JavaScript on the server is an open source server framework and free runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) Node.js can generate dynamic page content create, open, read, write, delete, and close files on the server collect form data add, delete, modify data in your databases A Node.js file operates on Certain events (e.g. access a port on the server) Activation on the server before having any effect, Node.js file has an extension “.js”

Asynchronous protocol of node.js Synchronous programming Server Side Client Side Web Server 1. HTTP request (e.g. read a file) Web Client 2. Wait the next request and process it 4. HTTP response 5. Get the results If the server waits only the request from one single client, it is excellent. Otherwise, the waiting is a waste of resources and multi-thread is required (not memory efficient)

Asynchronous protocol of node.js Asynchronous programming Message queue (mailbox) Server Side Client Side Web Server 1. HTTP request (e.g. read a file) Web Client 2. Read next request and process it when ready 3. HTTP response 4. Get the results No reason to wait at the server side, which improves the total utilization of server. Single thread and memory efficient.

Node.js installation and running a server You have to install Node.js® - JavaScript runtime environment Initiate your web server https://nodejs.org/en/ var http = require('http'); http.createServer(function (req, res) {     res.writeHead(200, {'Content-Type': 'text/html'});     res.end('Hello World!'); }).listen(8080) 'Hello World' when there is any access to port 8080

Message queue (mailbox) Example: myfirst.js Message queue (mailbox) myfirst.js Web Browser Web Server 1. HTTP request (simple access) Web Client 2. Read from 8080 port next request and make “hello world!” html message 3. HTTP response 4. Get the html message

Node.js Modules Node.js provides a set of built-in modules Descritpion assert Provides a set of assertion tests buffer To handle binary data child_process To run a child process cluster To split a single Node process into multiple processes crypto To handle OpenSSL cryptographic functions dgram Provides implementation of UDP datagram sockets dns To do DNS lookups and name resolution functions domain Deprecated. To handle unhandled errors events To handle events fs To handle the file system http To make Node.js act as an HTTP server https To make Node.js act as an HTTPS server. net To create servers and clients os Provides information about the operation system path To handle file paths punycode Deprecated. A character encoding scheme querystring To handle URL query strings readline To handle readable streams one line at the time stream To handle streaming data string_decoder To decode buffer objects into strings timers To execute a function after a given number of milliseconds tls To implement TLS and SSL protocols tty Provides classes used by a text terminal url To parse URL strings util To access utility functions v8 vm To compile JavaScript code in a virtual machine zlib To compress or decompress files Node.js provides a set of built-in modules To include a module var http = require('http');

HTTP Module Module that allows to transfer data via http as we have already seen var http = require('http'); http.createServer(function (req, res) {     res.writeHead(200, {'Content-Type': 'text/html'});     res.end('Hello World!'); }).listen(8080) 'Hello World' when there is any access to port 8080 Web Browser Web Server 1. HTTP request (simple access) Web Client 2. HTTP response

File System Module Module that allows you to work with the file system on your computer. Read files Create files Update files Delete files Rename files var fs = require('fs'); Client Side Server Side HTTP request Web Client – Browser (JavaScript) Web Server File System HTTP response var http = require('http'); var fs = require('fs'); http.createServer(function (req, res) {   fs.readFile('demofile1.html', function(err, data) {     res.writeHead(200, {'Content-Type': 'text/html'});     res.write(data);     res.end();   }); }).listen(8080)

File System Module Functions fs.appendFile() fs.open() fs.writeFile() fs.unlink() fs.rename var fs = require('fs'); fs.appendFile('mynewfile1.txt', 'Hello content!', function (err) {   if (err) throw err;   console.log('Saved!'); });

Event Module Module that allows to handle events To create, fire, or listen on events var events = require('events'); var eventEmitter = new events.EventEmitter(); var events = require('events'); var eventEmitter = new events.EventEmitter(); //Create an event handler: var myEventHandler = function () {   console.log('I hear a scream!'); } //Assign the event handler to an event: eventEmitter.on('scream', myEventHandler); //Fire the 'scream' event: eventEmitter.emit('scream');