SlideShare a Scribd company logo
WWW Introduction
Ensky / 林宏昱
What happened
when you open a browser?
DNS lookup
dns
what's the ip of facebook.com?
It's 173.252.110.27
HTTP protocol
GET /enskylin HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
HTTP Protocol
• Protocol between Browser <-> Web server
• Initially used to transmit documents in HTML format
• We know GET method now, but how about post
something to webserver?
What happened
when you post a form on
website?
Perform a POST in HTTP
POST /register HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
save to
database
surname=E&name=ensky&email=…
HTTP usage
• Actually, HTTP is very simple, trivial, and easy to use
in many situations
• When it comes to data-manipulation, there are four
basic method:
Create, Read, Update, Delete(CRUD)
they can be perfectly mapped into HTTP protocol
HTTP protocol -> REST API
• Using HTTP protocol to serve an data-manipulation
API, we call it REST API.
• WIKI: REST
Operation HTTP
Read GET
Create POST
Update PUT
Delete DELETE
Imagine you're writing a game
• you'll have
– character info
• maybe life, age, attack power, skills, location, …
– Monster info
• maybe life, skills, …
– and many data need to be CRUD
REST API
• And it'll be very easy if you use REST API.
– GET /characters/1/life
– PUT /characters/1
life=60&isPoisoned=1
– PUT /characters/1/location
map=1&block=123
What about HTML?
HyperText Markup Language
Insights
HTML is
a markup language
(not a programming language)
defines
defines what elements on the page
(images, links, texts, videos, forms, scripts, etc.)
http://goo.gl/qOu6OF
defines what orders the elements are
1
2
3
4
http://goo.gl/qOu6OF
HTML
• cooperates
–layouts with CSS
–functions with Javascript
CSS, HTML, JS
Structures Layouts Functions
結構 樣式 功能
HTML hello world
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello world! Title</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
HTML is a nested language
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello world! Title</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
HTML is a markup language
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>…</title>
</head>
<body>
<p>…</p>
</body>
</html>
• Tag
• Attribute
• Value
• Node
• Parent
• Children
HTML is a markup language
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>…</title>
</head>
<body>
<p>…</p>
</body>
</html>
• Head defines
something for
browser
• Encoding
• Title of the
page
• Resources
• CSS
• Javascript
HTML is a markup language
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>…</title>
</head>
<body>
<p>…</p>
</body>
</html>
• Body defines
something to
render
(the contents)
Common attributes
<p id="unique" class="red-div" title="help text">HIHI</p>
• class
classify elements, usually set for CSS or JS to select some
elements. One element can have multiple classes
• id
same as class, but unique in a document.
One element can only have one id
• style
inline CSS
• title
help text when hover
Debug tools
• Chrome debug tool F12
Debug tools
CSS, HTML, JS
Structures Layouts Functions
結構 樣式 功能
HTTP protocol review
GET /enskylin HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
Imagine if you want to
write a web server…
1.Initialize a socket
wait for client's HTTP request
GET /icon.png HTTP/1.1
Host: www.ensky.tw
HTTP/1.1 200 OK
HTML
port 80
2.Parse the HTTP request
find out some useful information
like URL, Hostname, …
GET /icon.png HTTP/1.1
Host: www.ensky.tw
HTTP/1.1 200 OK
HTML
3.Prepare file according to
above information
GET /icon.png HTTP/1.1
Host: www.ensky.tw
HTTP/1.1 200 OK
HTML
get icon.png from
somewhere in your file system
4.Response the document
back to client
GET /icon.png HTTP/1.1
Host: www.ensky.tw
HTTP/1.1 200 OK
HTML
Virtual host
• One web server can host many domains
• It can be determined by "Host: " part in HTTP
protocol
www.facebook.com
GET /enskylin HTTP/1.1
Host: www.facebook.com
Virtual host
• In case of static file mapping, you can simply do
www.facebook.com -> c:Domainswww
image.facebook.com -> c:Domainsimage
so any request to http://www.facebook.com/song.mp3
web server will try to find the file at
c:Domainswwwsong.mp3
However, static files is not rocks
enough!
How about dynamic generated
documents?
The only difference is we get data
from database
rather than disk file
GET /enskylin HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
And we need to generate the HTML
GET /enskylin HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
And send it back to browser
GET /icon.png HTTP/1.1
Host: www.ensky.tw
HTTP/1.1 200 OK
HTML
If you want to write a web server
1. Initialize a socket to wait for client's HTTP
request
2. Parse the HTTP request and find out some
useful information like URL, Host, …
3. Prepare document according to above
information
4. Response the document back to client
If you want to write a web server
1. Initialize a socket to wait for client's HTTP
request
2. Parse the HTTP request and find out some
useful information like URL, Host, …
3. Prepare document according to above
information
4. Response the document back to client
there is different logic for each page
-> it is hard to write in Web server
GET /enskylin HTTP/1.1
Host: www.facebook.com
HTTP/1.1 200 OK
HTML
If you want to write a web server
1. Initialize a socket to wait for client's
HTTP request
2. Parse the HTTP request and find out
some useful information like URL,
Host, …
3. Prepare document according to above
information
4. Response the document back to client
web
Server
CGI
CGI and Web server
Web server
CGI
HTTP Request
stdin + env
stdout
HTTP
Response
+ BODY
HTTP
request
body
HTTP
request
header
HTTP
response
head + body
CGI Implemention
#include <iostream>
using namespace std;
int main () {
cout << “<!doctype html>”;
cout << “<html>”;
cout << “ <head>”;
// …omitted
}
Any better choice?
We Save Your Time!
Next two weeks
References
IDE
• We highly recommended to use
IDE Note
• You must save in UTF-8, otherwise you'll not be able
to render Chinese correctly
• see: ChineseWorld PTT
Save as UTF-8
• Notepad++
Save as UTF-8
• Sublime
Save as UTF-8
• VIM
• Putty
HTML Tags - Text
p: paragraph
<p>Jlhuang Rocks!</p>
HTML Tags - Text
br: break
<p>Jlhuang <br> Rocks!</p>
HTML Tags - Link
a: anchor
<a href="http://www.google.com">Click me</a>
HTML Tags - Heading
<h1>H1</h1>
<h2>H2</h2>
<h3>H3</h3>
<h4>H4</h4>
<h5>H5</h5>
<h6>H6</h6>
HTML Tags - List
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<ol>
<li>Item4</li>
</ol>
</ul>
HTML Tags - Table
<table>
<thead>
<tr><td>Name</th><td>Score</td></tr>
</thead>
<tbody>
<tr><th>Ensky</th><td>100</td></tr>
<tr><th>dy93</th><td>80</td></tr>
</tbody>
<tfoot>
<tr><th>Average</th><td>90</td></tr>
</tfoot>
</table>
Name Score
Ensky 100
dy93 80
Average 90
HTML Tags - Images
img: image
<img
src="http://i1.ytimg.com/vi/iYQHkwCfCiw/m
axresdefault.jpg">
More Tags
http://www.w3schools.com/tags/
CSS reference
• https://speakerdeck.com/openwebscho
ol/04-css-openwebschool
Javascript reference
• https://speakerdeck.com/openwebschool/07-javascript-
openwebschool
• https://speakerdeck.com/openwebschool/08-js-frontend-
and-jquery-openwebschool
WWW reference
https://speakerdeck.com/openwebschool

More Related Content

PDF
Html css workshop, lesson 0, how browsers work
PDF
Introduction to WordPress Theme Development
PPTX
Html and Xhtml
PPTX
The JSON REST API for WordPress
PDF
Introduction to WEB HTML, CSS
PDF
Cms & wordpress theme development 2011
PDF
HTML 5 Step By Step - Ebook
PPT
HTML5 CSS3 Basics
Html css workshop, lesson 0, how browsers work
Introduction to WordPress Theme Development
Html and Xhtml
The JSON REST API for WordPress
Introduction to WEB HTML, CSS
Cms & wordpress theme development 2011
HTML 5 Step By Step - Ebook
HTML5 CSS3 Basics

What's hot (20)

PPT
Chapter2
PPT
Xhtml 2010
PPTX
WordPress Theme Development
PPTX
KEY
HTML/CSS Lecture 1
PDF
You Got React.js in My PHP
PDF
JSON REST API for WordPress
PPTX
PHP language presentation
PPT
En story of cakephp2.0
PPT
PDF
Using MongoDB and a Relational Database at MongoDB Day
PPT
html
PPTX
How the Web Works Using HTML
PPTX
PDF
WordPress Theme Development
PDF
Mastering the shortcode api
PPT
php 1
PPT
WordCamp Detroit 2010 Wordpress Theme Hacks
PPTX
Web technology P B Jadhav
PDF
Documentation Insight技术架构与开发历程
Chapter2
Xhtml 2010
WordPress Theme Development
HTML/CSS Lecture 1
You Got React.js in My PHP
JSON REST API for WordPress
PHP language presentation
En story of cakephp2.0
Using MongoDB and a Relational Database at MongoDB Day
html
How the Web Works Using HTML
WordPress Theme Development
Mastering the shortcode api
php 1
WordCamp Detroit 2010 Wordpress Theme Hacks
Web technology P B Jadhav
Documentation Insight技术架构与开发历程
Ad

Viewers also liked (7)

PDF
OpenWebSchool - 03 - PHP Part II
PDF
OpenWebSchool - 01 - WWW Intro
PDF
Google App Engine
PDF
PDF
2014 database - course 2 - php
PDF
OpenWebSchool - 11 - CodeIgniter
PDF
2014 database - course 3 - PHP and MySQL
OpenWebSchool - 03 - PHP Part II
OpenWebSchool - 01 - WWW Intro
Google App Engine
2014 database - course 2 - php
OpenWebSchool - 11 - CodeIgniter
2014 database - course 3 - PHP and MySQL
Ad

Similar to 2014 database - course 1 - www introduction (20)

PPT
PPT
A detailed presentation on the World Wide Web
ODP
PHP Training: Module 1
PDF
Unit 02: Web Technologies (1/2)
PPTX
Web technology Unit I Part C
PPT
21 Www Web Services
PPT
www | HTTP | HTML - Tutorial
PPTX
IP UNIT 1.pptx
KEY
Webapp security testing
KEY
Webapp security testing
PDF
Lab1-FrontEndTraining For everybody..pdf
ODP
Starting With Php
PPTX
Www and http
PDF
Introduction To Web (Mukesh Patel)
PPT
world wide web and internet evolution topics
PDF
world wide web and its evolution and reference topics
PPT
The world wide web science and technology.00000002ppt
PPT
The world wide web.00000000000000354748ppt
PPT
A detailed presentation on the World Wide Web
PHP Training: Module 1
Unit 02: Web Technologies (1/2)
Web technology Unit I Part C
21 Www Web Services
www | HTTP | HTML - Tutorial
IP UNIT 1.pptx
Webapp security testing
Webapp security testing
Lab1-FrontEndTraining For everybody..pdf
Starting With Php
Www and http
Introduction To Web (Mukesh Patel)
world wide web and internet evolution topics
world wide web and its evolution and reference topics
The world wide web science and technology.00000002ppt
The world wide web.00000000000000354748ppt

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
KodekX | Application Modernization Development
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KodekX | Application Modernization Development
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
Review of recent advances in non-invasive hemoglobin estimation
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectral efficient network and resource selection model in 5G networks
Digital-Transformation-Roadmap-for-Companies.pptx

2014 database - course 1 - www introduction

  • 2. What happened when you open a browser?
  • 3. DNS lookup dns what's the ip of facebook.com? It's 173.252.110.27
  • 4. HTTP protocol GET /enskylin HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML
  • 5. HTTP Protocol • Protocol between Browser <-> Web server • Initially used to transmit documents in HTML format • We know GET method now, but how about post something to webserver?
  • 6. What happened when you post a form on website?
  • 7. Perform a POST in HTTP POST /register HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML save to database surname=E&name=ensky&email=…
  • 8. HTTP usage • Actually, HTTP is very simple, trivial, and easy to use in many situations • When it comes to data-manipulation, there are four basic method: Create, Read, Update, Delete(CRUD) they can be perfectly mapped into HTTP protocol
  • 9. HTTP protocol -> REST API • Using HTTP protocol to serve an data-manipulation API, we call it REST API. • WIKI: REST Operation HTTP Read GET Create POST Update PUT Delete DELETE
  • 10. Imagine you're writing a game • you'll have – character info • maybe life, age, attack power, skills, location, … – Monster info • maybe life, skills, … – and many data need to be CRUD
  • 11. REST API • And it'll be very easy if you use REST API. – GET /characters/1/life – PUT /characters/1 life=60&isPoisoned=1 – PUT /characters/1/location map=1&block=123
  • 14. HTML is a markup language (not a programming language)
  • 15. defines defines what elements on the page (images, links, texts, videos, forms, scripts, etc.) http://goo.gl/qOu6OF
  • 16. defines what orders the elements are 1 2 3 4 http://goo.gl/qOu6OF
  • 17. HTML • cooperates –layouts with CSS –functions with Javascript
  • 18. CSS, HTML, JS Structures Layouts Functions 結構 樣式 功能
  • 19. HTML hello world <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Hello world! Title</title> </head> <body> <p>Hello world!</p> </body> </html>
  • 20. HTML is a nested language <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Hello world! Title</title> </head> <body> <p>Hello world!</p> </body> </html>
  • 21. HTML is a markup language <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>…</title> </head> <body> <p>…</p> </body> </html> • Tag • Attribute • Value • Node • Parent • Children
  • 22. HTML is a markup language <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>…</title> </head> <body> <p>…</p> </body> </html> • Head defines something for browser • Encoding • Title of the page • Resources • CSS • Javascript
  • 23. HTML is a markup language <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>…</title> </head> <body> <p>…</p> </body> </html> • Body defines something to render (the contents)
  • 24. Common attributes <p id="unique" class="red-div" title="help text">HIHI</p> • class classify elements, usually set for CSS or JS to select some elements. One element can have multiple classes • id same as class, but unique in a document. One element can only have one id • style inline CSS • title help text when hover
  • 25. Debug tools • Chrome debug tool F12
  • 27. CSS, HTML, JS Structures Layouts Functions 結構 樣式 功能
  • 28. HTTP protocol review GET /enskylin HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML
  • 29. Imagine if you want to write a web server…
  • 30. 1.Initialize a socket wait for client's HTTP request GET /icon.png HTTP/1.1 Host: www.ensky.tw HTTP/1.1 200 OK HTML port 80
  • 31. 2.Parse the HTTP request find out some useful information like URL, Hostname, … GET /icon.png HTTP/1.1 Host: www.ensky.tw HTTP/1.1 200 OK HTML
  • 32. 3.Prepare file according to above information GET /icon.png HTTP/1.1 Host: www.ensky.tw HTTP/1.1 200 OK HTML get icon.png from somewhere in your file system
  • 33. 4.Response the document back to client GET /icon.png HTTP/1.1 Host: www.ensky.tw HTTP/1.1 200 OK HTML
  • 34. Virtual host • One web server can host many domains • It can be determined by "Host: " part in HTTP protocol www.facebook.com GET /enskylin HTTP/1.1 Host: www.facebook.com
  • 35. Virtual host • In case of static file mapping, you can simply do www.facebook.com -> c:Domainswww image.facebook.com -> c:Domainsimage so any request to http://www.facebook.com/song.mp3 web server will try to find the file at c:Domainswwwsong.mp3
  • 36. However, static files is not rocks enough!
  • 37. How about dynamic generated documents?
  • 38. The only difference is we get data from database rather than disk file GET /enskylin HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML
  • 39. And we need to generate the HTML GET /enskylin HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML
  • 40. And send it back to browser GET /icon.png HTTP/1.1 Host: www.ensky.tw HTTP/1.1 200 OK HTML
  • 41. If you want to write a web server 1. Initialize a socket to wait for client's HTTP request 2. Parse the HTTP request and find out some useful information like URL, Host, … 3. Prepare document according to above information 4. Response the document back to client
  • 42. If you want to write a web server 1. Initialize a socket to wait for client's HTTP request 2. Parse the HTTP request and find out some useful information like URL, Host, … 3. Prepare document according to above information 4. Response the document back to client
  • 43. there is different logic for each page -> it is hard to write in Web server GET /enskylin HTTP/1.1 Host: www.facebook.com HTTP/1.1 200 OK HTML
  • 44. If you want to write a web server 1. Initialize a socket to wait for client's HTTP request 2. Parse the HTTP request and find out some useful information like URL, Host, … 3. Prepare document according to above information 4. Response the document back to client web Server CGI
  • 45. CGI and Web server Web server CGI HTTP Request stdin + env stdout HTTP Response + BODY HTTP request body HTTP request header HTTP response head + body
  • 46. CGI Implemention #include <iostream> using namespace std; int main () { cout << “<!doctype html>”; cout << “<html>”; cout << “ <head>”; // …omitted }
  • 48. We Save Your Time!
  • 51. IDE • We highly recommended to use
  • 52. IDE Note • You must save in UTF-8, otherwise you'll not be able to render Chinese correctly • see: ChineseWorld PTT
  • 53. Save as UTF-8 • Notepad++
  • 54. Save as UTF-8 • Sublime
  • 55. Save as UTF-8 • VIM • Putty
  • 56. HTML Tags - Text p: paragraph <p>Jlhuang Rocks!</p>
  • 57. HTML Tags - Text br: break <p>Jlhuang <br> Rocks!</p>
  • 58. HTML Tags - Link a: anchor <a href="http://www.google.com">Click me</a>
  • 59. HTML Tags - Heading <h1>H1</h1> <h2>H2</h2> <h3>H3</h3> <h4>H4</h4> <h5>H5</h5> <h6>H6</h6>
  • 60. HTML Tags - List <ul> <li>Item1</li> <li>Item2</li> <li>Item3</li> <ol> <li>Item4</li> </ol> </ul>
  • 61. HTML Tags - Table <table> <thead> <tr><td>Name</th><td>Score</td></tr> </thead> <tbody> <tr><th>Ensky</th><td>100</td></tr> <tr><th>dy93</th><td>80</td></tr> </tbody> <tfoot> <tr><th>Average</th><td>90</td></tr> </tfoot> </table> Name Score Ensky 100 dy93 80 Average 90
  • 62. HTML Tags - Images img: image <img src="http://i1.ytimg.com/vi/iYQHkwCfCiw/m axresdefault.jpg">
  • 65. Javascript reference • https://speakerdeck.com/openwebschool/07-javascript- openwebschool • https://speakerdeck.com/openwebschool/08-js-frontend- and-jquery-openwebschool