Introduction to HTTP - Hypertext Transfer Protocol

37

Transcript of Introduction to HTTP - Hypertext Transfer Protocol

Page 1: Introduction to HTTP - Hypertext Transfer Protocol
Page 2: Introduction to HTTP - Hypertext Transfer Protocol

Check all our Python Courses at: https://rmotr.com

Introduction to Python online courseAdvanced Python Programming Online CourseWeb Development with Django Online Course

Page 3: Introduction to HTTP - Hypertext Transfer Protocol

Flask Tutorial - Step by Step

CLIENT - SERVER

Page 4: Introduction to HTTP - Hypertext Transfer Protocol

SERVERCLIENT

Our Flask webapp

Page 5: Introduction to HTTP - Hypertext Transfer Protocol

SERVERCLIENT

Our Flask webapp

Client Request

Page 6: Introduction to HTTP - Hypertext Transfer Protocol

SERVERCLIENT

Our Flask webapp

Client Request

Server Response

Page 7: Introduction to HTTP - Hypertext Transfer Protocol

CLIENT SERVER

Our Flask webapp

Client Request

Server Response

Page 8: Introduction to HTTP - Hypertext Transfer Protocol

Flask Tutorial - Step by Step

HTTP

Page 9: Introduction to HTTP - Hypertext Transfer Protocol

Flask Tutorial - Step by Step

🙌 HTTP 🙌

Page 10: Introduction to HTTP - Hypertext Transfer Protocol

HTTP

HTTP is a stateless, text-based protocol

Page 11: Introduction to HTTP - Hypertext Transfer Protocol

SERVERCLIENT

Our Flask webapp🤔

GET /intro-to-python HTTP/1.1Host: rmotr.comAccept: text/html

Page 12: Introduction to HTTP - Hypertext Transfer Protocol

Example: Browsing http://rmotr.com

Page 13: Introduction to HTTP - Hypertext Transfer Protocol

Client Request

SERVERCLIENT

Our Flask webapp

Page 14: Introduction to HTTP - Hypertext Transfer Protocol

Client RequestGET /intro-to-python

HTTP/1.1

Page 15: Introduction to HTTP - Hypertext Transfer Protocol

Client RequestGET /intro-to-python

HTTP/1.1

PATH

Page 16: Introduction to HTTP - Hypertext Transfer Protocol

Client RequestGET /intro-to-python

HTTP/1.1

HTTP VERSION

Page 17: Introduction to HTTP - Hypertext Transfer Protocol

Client RequestGET /intro-to-python

HTTP/1.1

HTTP METHOD

Page 18: Introduction to HTTP - Hypertext Transfer Protocol

HTTP MethodsGET /intro-to-python

HTTP/1.1POST: Create resourcePUT: Update resourcePATCH: Update resourceDELETE: Delete resourceHEAD: ExtrasOPTIONS: Extras

Page 19: Introduction to HTTP - Hypertext Transfer Protocol

Client Request

GET /tweet/3123 HTTP/1.1POST /tweet HTTP/1.1DELETE /tweet/3123 HTTP/1.1

Page 20: Introduction to HTTP - Hypertext Transfer Protocol

Client Request

SERVERCLIENT

Our Flask webapp

Server Response

Page 21: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 200 OK

<html> <h1>Introduction to Python Programming</h1></html>

Server Response

Page 22: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 200 OK

<html> <h1>Introduction to Python Programming</h1></html>

Server Response

HTTP VERSION

Page 23: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 200 OK

<html> <h1>Introduction to Python Programming</h1></html>

Server Response

BODY

Page 24: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 200 OK

<html> <h1>Introduction to Python Programming</h1></html>

Server ResponseSTATUS CODE

Page 25: Introduction to HTTP - Hypertext Transfer Protocol

STATUS CODES2XX: SUCCESS3XX: REDIRECTION4XX: CLIENT ERROR5XX: SERVER ERROR

Page 26: Introduction to HTTP - Hypertext Transfer Protocol

EXAMPLE

bit.ly/rmotr-flask-tutorial

Page 27: Introduction to HTTP - Hypertext Transfer Protocol

CLIENT

rmotr.com

GET /rmotr-flask-tutorial HTTP/1.1Host: bit.ly

Page 28: Introduction to HTTP - Hypertext Transfer Protocol

CLIENT

rmotr.com

GET /rmotr-flask-tutorial HTTP/1.1Host: bit.ly

HTTP/1.1 301 Moved PermanentlyLocation: rmotr.com

Page 29: Introduction to HTTP - Hypertext Transfer Protocol

CLIENT

rmotr.com

GET /rmotr-flask-tutorial HTTP/1.1Host: bit.ly

HTTP/1.1 301 Moved PermanentlyLocation: rmotr.com

Page 30: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 400 Bad Request

OTHER EXAMPLES

POST /tweet HTTP/1.1

Page 31: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 404 Not Found

OTHER EXAMPLES

GET /XYZ HTTP/1.1

Page 32: Introduction to HTTP - Hypertext Transfer Protocol

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

MORE STATUS CODES

Page 33: Introduction to HTTP - Hypertext Transfer Protocol

Flask Tutorial - Step by Step

HTTP HEADERS

Page 34: Introduction to HTTP - Hypertext Transfer Protocol

Headers will allow Clients and Servers to include additional information

HTTP HEADERS

Page 35: Introduction to HTTP - Hypertext Transfer Protocol

HTTP HEADERS

Can be included in Requests and Responses

Page 36: Introduction to HTTP - Hypertext Transfer Protocol

GET /intro-to-python HTTP/1.1Host: rmotr.comUser-Agent: Mozilla/5.0Accept: text/htmlAccept-Encoding: gzip

Request with Headers

Page 37: Introduction to HTTP - Hypertext Transfer Protocol

HTTP/1.1 200 OKServer: ApacheContent-Type: text/htmlContent-Length: 16824

Response with Headers

<html> <h1>rmotr.com</h1></html>