All about Python Web Frameworks

Alkesha B.
5 min readSep 11, 2019

--

just a meme

When you start learning python most of us are curious about what project should I do using python language. Well, there are many options like a desktop app, mobile app, and websites. But how do I start web development using python that's the question we always have… here I will give you an introduction to different python web frameworks use as the backend for websites.

These web frameworks help you create server-side code(backend code ) in python.

We need a web framework because a web framework makes it easier to build backend logic. This includes mapping different URLs to chunks of Python code, dealing with databases, and generating HTML files users see on their browsers.

Why do we use Frameworks?

  1. They allow you not to build everything from scratch
  2. They follow the latest patterns
  3. They allow you to attach useful third-party resources

Types of web frameworks -

1. full-stack framework

2. microframework

3. asynchronous framework

Full-stack framework -

The full-stack frameworks provide complete support to developers, including necessary elements such as form validation, form generators, and template layouts, etc.

Types of the full-stack framework:

1. Django:

Django is one of the most popular web development frameworks for developing Python applications. Django framework follows the DRY (Don’t Repeat Yourself) principle. Django makes use of its ORM for mapping objects to database tables.

Features of Django:

  • Since Django uses Python, it has the power of python to its own benefit.
  • It allows you to take a lot of different actions regarding scalability such as running separate servers for the database, the media and the application itself or even use clustering or load-balancing to distribute the application across multiple servers.
  • It has a built-in admin which is able to manage data with basic CRUD operations. It’s quite unreasonable to create your own admin interface at the backend just to be able to manage your data with basic CRUD operations.

2. web2py:

Web2py is a very easy-to-use and productive web framework. It provides everything you need to write a web app. A major goal of web2py is ease of use, from setup to learning, to coding, to distribution, to deployment.

Features of web2py:

  • Web-based IDE/admin to create, manage, and edit apps and plugins, including database administration, code editing and debugging, etc.
  • Built-in Ajax support and Ajax components
  • Easy default routing, with optional parameter and pattern-based rewrite systems for additional flexibility.
  • Regular Python in views/templates so doesn’t need to learn a new template language.

3. CubicWeb :

CubicWeb is a full-stack web framework. CubicWeb is a well-defined Python semantic web application framework that focuses on quality, reusability, and efficiency. CubicWeb stands out among other Python web frameworks and is not easy to learn.

Features of CubicWeb:

  • CubicWeb opens for users some new features that were previously available only to app developers.
  • It has the power and flexibility of the Python programming language.
  • It also has a query language named RQL.
  • CubicWeb also gives support for multiple databases.

4. Pyramid :

Pyramid is another leading Python full-stack web framework. The pyramid could be called the opposite of Django to some extent because this framework is super easy to customize. It is better for complex projects, but it is also more complicated than Django.

Features of Pyramid -

  • It is one of the most flexible web frameworks of python.
  • By using Pyramid developer can create traditional routes-oriented RDBMS applications using SQLAlchemy.
  • In pyramid developer can choose anything among DBMSs, URL structure, Template style and many more.

5. TurboGears :

TurboGears is a data-driven, open-sourced, full-stack web application framework for Python. TurboGears is one of the most popular Python Web Frameworks. By using TurboGears developer can create a dynamic web application and can connect to the database easily

Features of TurboGears :

  • It supports Multi-Database.
  • It follows an MVC pattern.
  • Support for web servers such as Pylons.

Microframework -

A microframework is a term used to refer to the minimalistic web application framework. The idea is to keep the core simple but extensible. Microframework focuses on a particular need. Doesn’t try to do too much. It usually means if you need more, use additional libraries.

1. Flask :

Flask is classified into a micro-framework that means it has little to no dependencies on external libraries. Flask has two dependencies, they are-Werkzeug ( WSGI utility library) and Jinja2 (template engine). Flask is also easy to get started with as a beginner.

Features of Flask :

  • Flask is very simple and any newbie can try it even when he/she is aware of very little of python’s syntax.
  • Flask is the best one for small lightweight web applications serving. Additionally, it can be useful when you want a web interface for your software rather than the default system based UI.
  • The web-based interface provides similar UI across any platform.

2. Bottle :

Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module. There are no dependencies other than the Python Standard Library. It’s also an excellent learning tool for those just getting starting with web development. Bottle will be useful for developers looking for flexibility or people who want to build something really simple.

Features of bottle :

  • Small size.
  • Easy to deploy.
  • Faster than more powerful frameworks.
  • Ideal for small web-applications.

other microframeworks are CherryPy, Falcon, etc.

Asynchronous Framework :

After the release of its asyncio library in 3.5 version, Python acknowledged the impact of Node.js on web development and introduce two new keywords into the language asyn and await.

1. Tornado :

Tornado is a collection of asynchronous modules. These modules are also used to build a web framework module. Tornado is built specifically to handle asynchronous processes. Tornado is good for handling a lot of connections since it can respond to an incoming client, dispatch a request handler.

Features of Tornado -

  • offers real-time services and supports a large number of concurrent connections
  • It is very fast compared to all other Python Web frameworks.
  • Tornado also allows users to mix it with other frameworks.

2. Sanic :

Sanic is a “modern” framework. It doesn’t support Python version below 3.6. Sanic is under very active development and is still in its infancy as a web framework. Sanic is still so new because of that there are not many example applications and extensions for Sanic compared to other web frameworks.

Features of Sanic -

  • supports the simple and universal async/await syntax
  • doesn’t make you read loads of documentation

other asynchronous frameworks are Quart, Vibora, etc.

--

--

Alkesha B.

Machine Learning Enthusiast | Software Engineer | Learner