Lesson 10: Frameworks

Homepage Content Slides Video

Warning

This lesson is under construction. Learn from it at your own risk. If you have any feedback, please fill out our General Feedback Survey.

Frameworks

  • Web-development frameworks.
  • Game-development frameworks.

The job of a framework

To take care of the boring stuff.

Why and When to use a Framework

Use a framework if you are making a cookie cutter application.

If a framework exists for what you’re doing, consider using it.

Types of Frameworks

  • Testing Frameworks
  • Web-app Frameworks
  • Game Frameworks

Web Frameworks

Static vs Dynamic Sites

There are two types of websites: Static and Dynamic.

Static Site
Rarely changes, looks the same for all visitors (Blog, News, Document)
Dynamic Site
Changes based on who you are and what you do. (Search Engine, Login)

Note: Model, View, Controller

model view controller diagram

URL Routing

app.route('/delete', delete_account)
def delete_account():
    if username was passed in the query parameters
        and password was passed in the query parameters
        and the user is in the database
        and passed password is correct

        database.remove_user(username)
        return success
    else
        return failure

Templating Engines (mad-libs!)

data = {"animal": "Cat", "number": 5}
template.render("You have {{ number }} {{ animal}}s! That's crazy.", data)
You have 5 cats! That's crazy.

TODO: Dynamic Website

Read the documentation on Flask, a simple Python Web-Framework and build a simple “Display the Time in each Timezone” Application.

When a user goes to our website they will see the server’s time and when they go to app-url/<timezone code> they will see the timezone in that area of the world.( http://flask.pocoo.org )

Further Reading