Summary of trending Python frameworks for 2022 recommended by corporate engineers

overview

As more and more developers use Python, it makes sense to use Python frameworks to enable them to develop more applications.

Python is suitable for machine learning, large-scale computation, and scraping, and building them from scratch consumes a lot of effort, and various frameworks have been created to solve it. .

As a result, developers are sure to waste a lot of time choosing which framework to use. This is because each framework has its own system, advantages, and ideas, and they have various advantages and disadvantages.

Here are the frameworks to choose from when using Python in 2022.

name | PyPI | Stars | Recommended | | ————————————————- - | ———————————- | —– | ——- —- | | Django | https://pypi.org/project/Django/ | 58K | | CubicWeb | https://pypi.org/project/cubicweb/ | | ○ | | Giotto | https://pypi.org/project/giotto/ | 54 | | AIOHTTP | https://pypi.org/project/aiohttp/ | 11K | ○ | | Growler | https://pypi.org/project/growler/ | 0.6K | | Sanic | https://pypi.org/project/sanic/ | 1.5K | | tornado | https://pypi.org/project/tornado/ | | CherryPy | https://pypi.org/project/CherryPy/ | 1K | ○ | | Flask | https://pypi.org/project/Flask/ | 5.5K | ○ |

Django

Django is a full-stack Python framework. Many engineers turn to Django when they want to develop Python applications.

A full-stack framework is a framework that provides forms, validations, templates, etc., which are necessary functions for web applications. Django is one of them.

Django is open source and has a great deal of built-in functionality, many of which are freely available to developers. It also uses an ORM to even map to database tables.

ORM is called “object relationship mapping”, and it is a big advantage that you can intuitively use database operations as objects. And it supports various databases such as MySQL, Postgres and SQLite.

merit

  1. Mature support Django has been around for a long time, having been released in 2005, and already has excellent support and extensive documentation. There are many Japanese developers, so even if a bug occurs in your application, it is possible to investigate immediately.
  2. Authentication support Creating an authentication function for a web application is very difficult. Database authentication settings, session cookie settings, and all sorts of other difficulties hit you. Django already comes bundled with authentication functionality. There is no doubt that using it will require minimal development effort.
  3. ORM support ORM stands for “Object Relational Mapping”. Using an ORM will make your database operations more intuitive.
  4. Web server support Django acts as a web server by itself. There is no need to create separate backend and frontend configurations.
  5. Template engine support Django has a template engine. By using it, you can output as much server data to the front as you like.
  6. Creating Sitemaps sitemap is an important file. This is because it will not be indexed unless you notify the Google crawler of your site’s update. Django has the ability to create Sitemaps.

Demerit

  1. Not suitable for small projects Django has a lot of bundled features. Therefore, it is necessary to learn the technology to use it one by one, so it is not suitable for small-scale projects.

Sample code

from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

Author Rating

The Django framework is great for large projects and very efficient. This is because the architecture called MVT (Model View Template) ensures code maintainability. Furthermore, it is equipped with an ORM layer, and all complex queries and procedures can be written in Python. These improve readability and reduce learning costs as developers don’t have to understand complex SQL.

In addition, Django has a wealth of documentation and tutorials, so it is recommended for beginners.

CubicWeb

CubicWeb is a full-stack Python framework. This could be an alternative to Django.

It has as many functions as Django, and the functions you create can be easily reused in units called components.

The functions listed on the official website are as follows.

  • an engine driven by the application’s explicit data model
  • A query language named RQL similar to W3C’s SPARQL.
  • selection + view mechanism for semi-automatic XHTML/XML/JSON/text generation
  • Reusable components to meet common needs Libraries for (data models and views)
  • The power and flexibility of the Python programming language
  • Storage backend SQL database, LDAP directory, Subversion, Mercurial reliability

merit

  1. OWL and RDF support OWL stands for (Web Ontology Language) and is a data description language for exchanging data using ontologies that exist on the Internet. RDF stands for (Resource Description Framework) and is a [computer language](https://ja.wikipedia.org/wiki/%E3%82%B3% E3%83%B3%E3%83%94%E3%83%A5%E3%83%BC%E3%82%BF%E8%A8%80%E8%AA%9E). CubicWeb supports these.
  2. Reusability CubicWeb can divide functions into individual components. They are available as many reusable functions as you like.
  3. Multiple database support

Demerit

  1. Lack of support It’s been more than 20 years since it was released, but Japanese support is not perfect, and Japanese documentation is lacking. If you are Japanese and use CubicWeb, you will be required to develop disadvantageously.

Sample code

def include(config):
    # ...
    config.include('cubicweb.pyramid')
    # ...

Author Rating

To be added

Giotto

Giotto is a full-stack Python framework. This could be an alternative to Django.

Giotto is a full-stack web framework for MVC (Model View Controller) development.

By doing MVC development, the roles of developers can be divided between the front end and the back end, and work can be done efficiently.

merid

  • MVC development pattern You can develop with MVC. If you’re familiar with MVC development, Django is a better choice.
  • concise code Less than 300 lines to create a full-featured blogging application.
  • Automatic URL routing It automatically creates routes based on the created controller.
  • Built-in cache support It supports Redis and Memcache. APIs are provided to support those engines.

Demerit

  • Lack of support It’s been more than 7 years since it was released, but Japanese support isn’t perfect, and Japanese documentation is lacking. When using Giotto in Japan, disadvantageous development will be required.

Sample code

from giotto.programs import ProgramManifest, GiottoProgram
from giotto.views import jinja_template, BasicView
def multiply(x, y):
    x = int(x or 0)
    y = int(y or y)
    return {'x': x, 'y': y, 'result': x * y}
manifest = ProgramManifest({
    'multiply': GiottoProgram(
        model=[multiply],
        view=BasicView(
            html=jinja_template('multiply.html'),
        ),
    ),
})

Author Rating

It has a controller module that allows you to create apps on the command line like NestJs and Angular, making development very efficient. Even beginners can instantly create controllers and models on the command line, so you don’t have to worry about the first connection part.

A highly recommended Python framework.

AIOHTTP

AIOHTTP is an asynchronous **Python framework**. Applications that can communicate asynchronously are in high demand in recent years. AIOHTP is one such asynchronous framework.

An asynchronous framework is one that allows many concurrent connections and does not pass communication delays to the user. As such, it is the top choice for those looking to improve the user experience.

merit

  1. Template engine support AIOHTTP has a template engine. By using it, you can output as much server data to the front as you like.
  2. Strong socket support It’s no secret that traditional socket communication can easily lead to callback hell when it comes to writing program code. There is no such thing because AIOHTTP performs communication processing asynchronously. Write as much readable code as you want
  3. Middleware support You can create middleware. By using middleware, it is possible to execute predetermined processing before and after communication.

Demerit

To be added

Sample code

import aiohttp
import asyncio
async def main():
    async with aiohttp.ClientSession() as session:
        async with session.get('http://python.org') as response:
            print("Status:", response.status)
            print("Content-type:", response.headers['content-type'])
            html = await response.text()
            print("Body:", html[:15], "...")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Growler

Growler is an asynchronous Python framework. Applications that can communicate asynchronously are in high demand in recent years. Growler is one such asynchronous framework.

This framework is inspired by the Express framework and is good at implementing complex applications easily. It is also a very lightweight framework.

merit

  1. Articulated code flow Asynchronous processing by async and no try/exception block in the callback function, so you can expect the code to be very easy to understand.
  2. Complete with many open source packages An open source package has been created by volunteers. By using this, the development period can be shortened.

Demerit
To be added

Sample code

import asyncio
from growler import App
from growler.middleware import (Logger, Static, StringRenderer)
loop = asyncio.get_event_loop()
# Construct our application with name GrowlerServer
app = App('GrowlerServer', loop=loop)
# Add some growler middleware to the application
app. use(Logger())
app.use(Static(path='public'))
app.use(StringRenderer("views/"))
# Add some routes to the application
@app.get('/')
def index(req, res):
    res.render("home")
@app.get('/hello')
def hello_world(req, res):
    res.send_text("Hello World!!")
# Create the server - this automatically adds it to the asyncio event loop
Server = app.create_server(host='127.0.0.1', port=8000)
# Tell the event loop to run forever - this will listen to the server's
# socket and wake up the growler application upon each connection
loop.run_forever()

Sanic

Sanic is an asynchronous Python framework. Applications that can communicate asynchronously are in high demand in recent years. Sanic is one such asynchronous framework.

Sanic, as the name suggests, is a simple open source framework specifically developed to provide fast HTTP responses. If you’re looking for fast web applications, Sanic is the choice.

Sanic also supports asynchronous request handlers, making it compatible with asynchronous functions such as async/await. As a result, not only is the HTTP response fast, but requests can be processed non-blocking.

merid

  1. High speed processing Faster than other asynchronous Python frameworks.
  2. Bundling cookies functionality Bundles functionality for manipulating cookies. No new installation required.

Demerit

  1. Lack of Japanese documents There is currently a shortage of Sonic developers. It will be difficult to refer to error contents and best practices in Japanese documents,

Sample code

from sanic import Sanic
from sanic.response import json
app = Sanic("My Hello, world app")
@app.route('/')
async def test(request):
    return json({'hello': 'world'})
if __name__ == '__main__':
    app.run()

Tornado

Tornado is an asynchronous Python framework. Applications that can communicate asynchronously are in high demand in recent years. Tornado is one such asynchronous framework.

Tornado provides a solution for Apache’s C10k problem and non-blocking processing. Even simpler and faster. This makes Tornado an excellent choice for delivering high performance websites to large numbers of users.

merit

  1. Template engine support Tornado has a template engine. By using it, you can output as much server data to the front as you like.
  2. High performance Very fast.
  3. Translation support Easy to implement multilingual support. 4.Facebook support The development company has been acquired by Facebook, and Facebook now supports it. Good quality will get support.

Demerit

  1. Lack of Japanese documents There is a lack of Japanese sites and no translation sites. It will be difficult to refer to error contents and best practices in Japanese documents,

Sample code

import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")
def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])
if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

CherryPy

The most popular open source object-oriented framework.

CherryPy is the oldest micro-framework. A micro-micro framework is a lightweight framework that provides only the minimum necessary functions, unlike a full-stack framework, and developers must develop necessary functions by themselves.

A web application built with CherryPy runs as a standalone web application with a built-in web server, so it runs on any OS and does not require a server application such as Apache.

merid

  1. Diverse tools CherryPy is a microframework, but it covers a lot of commonly used functions. Authentication, sessions, cookies, static content, etc. are readily available.
  2. Object-oriented Object-oriented, which is rare in Python frameworks. Recommended for those who have experience with programming languages ​​such as Java.
  3. Lightweight Being a micro-framework, it is very lightweight. If you are concerned about site speed, you can be selected.
  4. Fast and stable CherryPy has been supporting web application development for over 10 years. Over the years, it has proven to be able to provide fast and stable web applications.

Demerit

To be added

Sample code

import cherrypy
class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello World!"
cherrypy.quickstart(HelloWorld())

Flasks

Django is a popular framework. Flask is a micro-framework available under the BSD license.

A micro-framework is a lightweight framework that provides only the minimum necessary functions, unlike full-stack frameworks, and developers must develop necessary functions by themselves.

Flask is a microframe, so developers have to provide the functionality they need, but we can build a solid web application foundation to help them develop it.

merit

  1. Extremely lightweight It is very lightweight because it has only the minimum necessary functions. Developers only get the functionality they really need.
  2. Customizability It has just the functionality you need and already has a foundation that makes it easy to extend. By using the base, you can develop plug-ins very easily.
  3. Very memorable A microframework only has the functionality you need. Flask is such a framework, so you can catch up with just the features you really need.

Demerit

  1. You need to spend time on the front end Creating a web application with Flask alone is possible, but difficult. If you want to do everything in one framework, use Django.

Sample code

# save this as app.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
    return "Hello, World!"

summary

Development using a framework is essential in recent Python application development. This is because the development period can be greatly shortened. If you are an engineer, take full advantage of this advantage.

There are other Python frameworks besides those on this list. If you have time, you may want to look into other options as well.

Each Python framework has its pros and cons, and you have to consult with the project to decide which one to take advantage of.

We hope you can choose the best Python framework.