Introduction to HTTP - Hypertext Transfer Protocol

Post on 16-Apr-2017

32 views 1 download

Transcript of 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

Flask Tutorial - Step by Step

CLIENT - SERVER

SERVERCLIENT

Our Flask webapp

SERVERCLIENT

Our Flask webapp

Client Request

SERVERCLIENT

Our Flask webapp

Client Request

Server Response

CLIENT SERVER

Our Flask webapp

Client Request

Server Response

Flask Tutorial - Step by Step

HTTP

Flask Tutorial - Step by Step

🙌 HTTP 🙌

HTTP

HTTP is a stateless, text-based protocol

SERVERCLIENT

Our Flask webapp🤔

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

Example: Browsing http://rmotr.com

Client Request

SERVERCLIENT

Our Flask webapp

Client RequestGET /intro-to-python

HTTP/1.1

Client RequestGET /intro-to-python

HTTP/1.1

PATH

Client RequestGET /intro-to-python

HTTP/1.1

HTTP VERSION

Client RequestGET /intro-to-python

HTTP/1.1

HTTP METHOD

HTTP MethodsGET /intro-to-python

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

Client Request

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

Client Request

SERVERCLIENT

Our Flask webapp

Server Response

HTTP/1.1 200 OK

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

Server Response

HTTP/1.1 200 OK

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

Server Response

HTTP VERSION

HTTP/1.1 200 OK

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

Server Response

BODY

HTTP/1.1 200 OK

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

Server ResponseSTATUS CODE

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

EXAMPLE

bit.ly/rmotr-flask-tutorial

CLIENT

rmotr.com

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

CLIENT

rmotr.com

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

HTTP/1.1 301 Moved PermanentlyLocation: rmotr.com

CLIENT

rmotr.com

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

HTTP/1.1 301 Moved PermanentlyLocation: rmotr.com

HTTP/1.1 400 Bad Request

OTHER EXAMPLES

POST /tweet HTTP/1.1

HTTP/1.1 404 Not Found

OTHER EXAMPLES

GET /XYZ HTTP/1.1

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

MORE STATUS CODES

Flask Tutorial - Step by Step

HTTP HEADERS

Headers will allow Clients and Servers to include additional information

HTTP HEADERS

HTTP HEADERS

Can be included in Requests and Responses

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

Request with Headers

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

Response with Headers

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