Slide 1

Slide 1 text

Let’s learn Flask By : smit thakkar and parth jansari

Slide 2

Slide 2 text

● I work for Lendcypher as a Full Stack Developer. ● I am author of an open source Flask extension : Flask-NSFW and Flask-ReqParse ● Former Technical Co-Founder at Punchit.io. ● Technology Stack : Python FLask, AngularJs, Mongodb, SQL, Native ios apps with Swift. ● Hackathon Lover ● Email : [email protected] ● Github : github.com/smitthakkar96 ● Facebook : https://www.facebook.com/geekysmit Who Am I?

Slide 3

Slide 3 text

Agenda ● Tools with which we are gonna hack on ● Why Flask? ● Setup ● Example Application Demonstration ● Let’s build an Application ○ Hello, Flask! ○ Rest APIs ○ Request and Response ○ on mechanism ○ Let’s build a todo apps ● What’s next?

Slide 4

Slide 4 text

Frameworks and Tools ● Python ● FLask ● SQLite

Slide 5

Slide 5 text

Setup ● Python Interpreter ○ Python 3.5 or Python 3.4 ○ Python 2.7 + virtualenv ● Pip install flask

Slide 6

Slide 6 text

Why Flask? ● Small, lightweight, straightforward. ● Adapts easily to the way of your thinking. ● Plays well with third party packages. ● Lot many open source Flask-Extensions (Even easy to create one) ● Largest community

Slide 7

Slide 7 text

Some Known FLask Extensions ● Flask-Admin ● Flask-SQlAlchemy ● Flask-NSFW ● Flask-MongoAlchemy ● Flask-CORS ● Flask-WTF ● Flask-Cache ● And much more..

Slide 8

Slide 8 text

Hello Flask! ● Create a project directory ● Create a virtual environment ● Install Flask

Slide 9

Slide 9 text

REST API REST is a software design pattern typically used for web applications. In layman's terms this means that it is a commonly used idea used in many different projects. It stands for REpresentational State Transfer. The basic idea of REST is treating objects on the server-side (as in rows in a database table) as resources than can be created or destroyed. The most basic way of thinking about REST is as a way of formatting the URL's of your web applications. For example, if your resource was called "posts", then: /posts Would be how a user would access ALL the posts, for displaying. /posts/:id Would be how a user would access and view an individual post, retrieved based on their unique id. /posts/new Would be how you would display a form for creating a new post. Sending a POST request to /users would be how you would actually create a new post on the database level. Sending a PUT request to /users/:id would be how you would update the attributes of a given post, again identified by a unique id.

Slide 10

Slide 10 text

HTTP Requests ● HTTP GET ● HTTP PUT ● HTTP POST ● HTTP DELETE

Slide 11

Slide 11 text

Flask ReqParse Demo

Slide 12

Slide 12 text

Response codes ● 200 - ok ● 400 - Bad Request ● 401 - unauthorized ● 403 - forbidden ● 404 - not found ● 500 - internal server error

Slide 13

Slide 13 text

SQLite3

Slide 14

Slide 14 text

SQLITE URI FORMAT: sqlite:////absolute/path/to/foo.db

Slide 15

Slide 15 text

SQLite Supported data types Integer an integer String (size) a string with a maximum length Text some longer unicode text DateTime date and time expressed as Python datetime object. Float stores floating point values Boolean stores a boolean value PickleType stores a pickled Python object Large Binary stores large arbitrary binary data

Slide 16

Slide 16 text

Let’s build a todo App

Slide 17

Slide 17 text

Any Questions

Slide 18

Slide 18 text

Feedback : http://bit.do/PythonWorkshop

Slide 19

Slide 19 text

Thank you