Fork me on GitHub

Web Framework

A web application framework is a collection of libraries that provide functionality to accomplish common operations for the web. These common operations include:

  1. URL routing
  2. HTML, XML, JSON, and other output format templating
  3. Database manipulation
  4. Security against Cross-site request forgery (CSRF) and other attacks

Not all web frameworks include functionality 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.

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 does not work (without modification) on non-relational databases such MongoDB and Riak. Other web frameworks such as Flask and Pyramid are generally easier to use with non-relational databases by incorporating external Python libraries.

Web Framework Monitoring

Logging is a common mechanism for monitoring web applications written with a web framework. Runtime exceptions that prevent code from running are important to log to investigate and fix the source of the problems. Informational and debugging logging also helps to understand how the application is performing even if code is working as intended.

Logging is often grouped into several categories:

  1. Information
  2. Debug
  3. Warning
  4. Error

Logging errors that occur while a web framework is running is crucial to understanding how your application is performing. Raven is a Python client for the Sentry exception logging and aggregation application. Raven provides the way to send exceptions to Sentry, which should be deployed on a separate server from your production infrastructure. Raven can also be used by Python scripts to send other log data to Sentry for aggregation. Sentry provides a clean web application interface for viewing the exceptions. Sentry can also be configured with a mail plugin to send emails when exceptions occur.

Web Framework Resources

Django, Flask, Bottle, Pyramid, and web.py are the most common Python web frameworks.


Next read about static content.