23 Oct Python Web Frameworks for Website Development
Python offers many web frameworks from which to choose from including bottle.py, Flask, CherryPy, Pyramid, Django and web2py. These frameworks have been used to power some of the world’s most popular sites such as Spotify, Mozilla, Reddit, the Washington Post and Yelp.
Django
Pyramid
Pyramid is an open-source Python-based web application framework. Its main goal is to do as much as possible with minimum complexity.
The most striking feature of Pyramid is its ability to work well with both small and large applications. Some of Pyramid’s great features include:
- Single-file applications
- URL generation
- Extensible configuration
- All-embracing templating and asset specifications
- Flexible authentication and authorization
- Testing, support, and comprehensive data documentation
- View predicates and many per-route views
- Function decorators
- Predicates
- Renders
TurboGears
TurboGears is an open-source, data-driven full-stack web application framework.It allows you to quickly develop extensible data-driven web applications. TurboGears comes with user-friendly templating and a powerful and flexible ORM.
Some of TurboGears’ distinctive features include:
- Multi-database support
- MVC-style architecture
- Support for SQLObject and SQLAlchemy
- Kid and Genshi included in preferred templating languages
- Validation with FormEncode
- Pylons as a web server
- ToscaWidgets, an application library that simplifies coordination of frontend design and server development
Web2py
Web2py is a scalable open-source full-stack Python framework. However, you should know before reading further that Web2py does not support Python 3.What’s great about Web2py, though, is that it comes with its own web-based IDEwhich, among other things, includes a code editor, debugger, and one-click deployment.
Other valuable Web2py features include:
- No requirements for installation and configuration
- Ability to run on Windows, Mac, Linux/Unix, Google App Engine, Amazon EC2, and any web hosting that supports either Python 2.5–2.7 or Java+Python
- Readability of multiple protocols
- Data security that prevents such vulnerabilities as cross-site scripting, injection flaws, and malicious file execution
- Successful employment of software engineering practices, making code easy to read and maintain
Flask
Flask is a Python framework available under the BSD license. It was inspired by the Sinatra Ruby framework. Flask depends on the Werkzeug WSGI toolkit and Jinja2template.The main idea behind Flask is to help build a solid web application foundation. From there, you can use any extensions you might need.
Flask’s lightweight and modular design makes it easily adaptable to developers’ needs. It includes a number of useful out-of-the-box features:
- Built-in development server and a fast debugger
- Integrated support for unit testing
- RESTful request dispatching
- Jinja2 templating
- Secure cookies support (client-side sessions)
- WSGI 1.0 compliance
Bottle
Bottle is a microframework. Originally meant for building APIs, Bottle implements everything in a single source file. It has no dependencies apart from the Python Standard Library. Coding with Bottle gets you closer to the metal than coding with any full-stack framework.
Its default features include routing, templating, utilities, and a basic abstraction over the WSGI standard.
- Routing — supports requests to function-call mapping, allowing you to achieve clean and dynamic URLs
- Templates — a fast and Pythonic template engine out of the box along with full support for mako, jinja2, and cheetah
- Utilities — comfortable access to form data, file uploads, cookies, headers, and other HTTP-related metadata
- Server — a built-in HTTP development server that supports fapws3, bjoern, GAE, СherryPy, and any other WSGI-capable HTTP server
Bottle is a perfect solution for prototyping, learning the organization of web frameworks, and building simple personal apps.