local hack day

25
digitalocean. com Intro to Web Development With Python/Flask By: Kaushal Parikh Local Hack Day December, 2014

Upload: kaushal-parikh

Post on 24-Jan-2017

179 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Local hack day

digitalocean.com

Intro to Web Development With Python/Flask

By: Kaushal ParikhLocal Hack Day December, 2014

Page 2: Local hack day

digitalocean.com

Who am I?

Kaushal Parikh

Student @Rutgers University

Evangelist @ DigitalOcean

Web Developer @ The Internet

Page 3: Local hack day

digitalocean.com

Overview

What is a web application?

Buzzwords/Terms: HTTP, REST, CRUD, Middleware, etc.

Data flow through web applications

How requests/responses work

Page 4: Local hack day

digitalocean.com

What is a web application?

Request

Response

Page 5: Local hack day

digitalocean.com

The User

Request

Response

Page 6: Local hack day

digitalocean.com

Your User

Makes requests

Typing in a url, form submissions, button clicks

Receives responses

Displays content

Page 7: Local hack day

digitalocean.com

curl -X GET http://www.google.com

Page 8: Local hack day

digitalocean.com

The Request

Request

Response

Page 9: Local hack day

digitalocean.com

The Request

Made over HTTP

Uses the HTTP methods

Typically uses the Rest Paradigm

Page 10: Local hack day

digitalocean.com

HTTP

Hyper Text Transport Protocol

Verbs:

GETPOSTPUTDELETE

Commonly Used Less Commonly Used

TRACECONNECTOPTIONSPATCHetc.

Page 11: Local hack day

digitalocean.com

REST

Representational State Transfer

Paradigm for how to use the HTTP verbs pragmatically

ExGET - get a resourceDELETE - delete resourcePOST - create new entry/resource

Page 12: Local hack day

digitalocean.com

The Application

Request

Response

Page 13: Local hack day

digitalocean.com

What is a server?

Server(hardware) vs Server(software)

Place where the application is running

Accepts requests

Sends response

HTTP Middleware

Page 14: Local hack day

digitalocean.com

Server (hardware)

Physical machine

Can have several programs/processes running on it

Page 15: Local hack day

digitalocean.com

Server (software)

Program that will accept requests and send responses

‘Back end’

Responsibilities:

Talking to databases

Keeping state

Page 16: Local hack day

digitalocean.com

HTTP Middleware

Parses and sanitizes requests

Makes sending responses easy

Page 17: Local hack day

digitalocean.com

The Response

Request

Response

Page 18: Local hack day

digitalocean.com

Response

Generated by server (software)

Types of responses:

HTML page

Strings

JSON

Page 19: Local hack day

digitalocean.com

Status codes

Also included in the response

Gives the users more information about the response1xx - Informational Codes2xx - Success! Received! Understood!3xx - Redirect4xx - Client Error Detected5xx - Server Error Detected

Page 20: Local hack day

digitalocean.com

Your web application!

Request

Response

Page 21: Local hack day

digitalocean.com

Lets write some code!

Example app in Python/Flask

https://github.com/kaushal/localhackday

Page 22: Local hack day

digitalocean.com

Conclusion

Web development isn’t that complicated

Data flow

Request/response

Use tools/frameworks

Ask for help!

Page 23: Local hack day

digitalocean.com

Helpful links

Flask - http://flask.pocoo.org/

HTTP - http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

HTTP status codes - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

REST - http://en.wikipedia.org/wiki/Representational_state_transfer

Page 24: Local hack day

digitalocean.com

Contact Info

Kaushal Parikh

[email protected]

https://twitter.com/cashbagel

https://github.com/kaushal

Page 25: Local hack day

digitalocean.com

The End.