Introduction to Flask

Ramit Malhotra

ramit@ischool.berkeley.edu

School of Information, UC Berkeley

What is Flask?

"Flask is a lightweight web application framework written in Python and based on the WSGI toolkit and Jinja2 template engine. It is BSD licensed."

.... What does this mean?
Flask is a microframework for Python that makes web development easy and fun!

Installing Flask

Flask workings

  1. A user issues a request for a domain's root URL / to go to its home page
  2. routes.py maps the URL / to a Python function
  3. The Python function finds a web template living in the templates/ folder.
  4. A web template will look in the static/ folder for any images, CSS, or JavaScript files it needs as it renders to HTML
  5. Rendered HTML is sent back to routes.py
  6. routes.py sends the HTML back to the browser

First swig from my Flask!

Download latest files from git And then add the following functionalities

  1. Add an item to the menu for 'register'
  2. Register is a page with a form that has a few form elements
  3. Submit form to server and return the information in another page

Resources