A web application framework is a code library that make a developer's life easier when building reliable, scalable and maintainable web applications.
Web frameworks encapsulate what developers have learned over the past twenty years while building dynamic web applications. Frameworks make it easier to reuse code for common HTTP operations and to structure your code so that it is maintainable.
Frameworks provide functionality in their code or through extensions to perform common operations required to run web applications. These common operations include:
Not all web frameworks include code for all of the above functionality. Frameworks fall somewhere between simply executing a single use case and attempting to be everything to every developer with increased complexity. Some frameworks take the "batteries-included" approach where everything possible comes bundled with the framework while others have a minimal code library that plays well with extensions.
For example, the Django web application framework includes an Object-Relational Mapping (ORM) layer that abstracts relational database read, write, query, and delete operations. However, Django's ORM cannot work without significant modification on non-relational databases such MongoDB. Some other web frameworks such as Flask and Pyramid are easier to use with non-relational databases by incorporating external Python libraries. There is a spectrum between minimal functionality with easy extensibility and including everything in the framework with tight integration.
Django is a widely used Python web application framework with a "batteries-included" philosophy. The principle behind batteries-included is that the common functionality for building web applications should come with the framework instead of as a separate library. For example, URL routing, a templating system, object-relational mapper, and database schema migrations (as of version 1.7) are all included with the Django framework.
2 Scoops of Django by Daniel Greenfield and Audrey Roy is well worth the price of admission if you're serious about learning how to correctly develop Django websites.
Effective Django and Tango with Django are a extensive free introductions to using the most popular Python web framework.
DjangoCon US videos from
2013,
2012,
2011, as well as
earlier US and DjangoCon EU conferences are
all available free of charge.
The Django subreddit often has links to the latest resources for learning Django.
Lincoln Loop wrote a Django Best Practices guide for the community.
Steve Losh wrote an incredibly detailed Django Advice guide.
GoDjango screencasts and tutorials are free short videos for learning how to build Django applications.
Flask is a Python microframework deliberately built with a small core and easy-to-extend philosophy. Flask is generally considered more Pythonic than Django because Flask web application code is often more explicit. Flask was also written several years after Django and therefore learned from the Python community's reactions as the framework evolved. Jökull Sólberg wrote a great piece articulating to this effect in his experience switching between Flask and Django.
The 18-part Flask mega tutorial is an absolutely amazing starting resource for using the Flask framework. Yes, there are a lot of posts in the series. However, each post is focused on a single topic to contain the complexity while the reader is learning the framework. The whole series is well worth an in-depth read-through. The author is also writing the O'Reilly Flask Web Development book so consider picking that up as well.
The Flask Extensions Registry is a curated list of the best packages that extend Flask. It's the first location to look through when you're wondering how to do something that's not in the core framework.
Great post by Jeff Knupp on Productionizing a Flask App
The Plank & Whittle blog has two posts, one on Packaging a Flask web app and another on Packaging a Flask app in a Debian package once you've built an app and want to deploy it.
The tuts+ Flask tutorial is another great walkthrough for getting started with the framework.
Bottle is a WSGI-compliant single source file web framework with no external dependencies except for the standard library included with Python.
The Tutorial on the official Bottle website provides a thorough view of basic concepts and features.
Digital Ocean provides an extensive introductory post on Bottle.
This tutorial provides a walkthrough for getting started with Bottle.
Here's a short code snippet for creating a REST API with Bottle and MongoDB.
Another snippet for executing CRUD operations on XML files.
"What is a web framework?" by Jeff Knupp is a in-depth explanation of what a web framework is and their relation to web servers.
Pyramid, Falcon, web.py are the most common Python web frameworks other than Django, Flask and Bottle.
This roundup of 14 minimal Python frameworks contains both familiar and less known Python libraries.
Good analysis on Python micro frameworks by Richard Jones, so you can choose the one most suited for your needs.