New Python web frameworks
As you understand, it is not possible to stop progress in any field, and constantly working with the same tools means not moving forward. This is very noticeable in IT, especially in the web development industry.
In regard to web frameworks, not long ago Django and Flask were new and advanced frameworks for Python, but new frameworks are appearing on the scene that are crowding out traditional and well-established technologies because they are better, more convenient, easier and faster.
Well-known Python web frameworks
This web framework is one of the most popular Python web frameworks. It allows you to make development simple, write understandable code, and quickly get comfortable with development. Django supports working with major databases such as MySQL, SQLite, PostgreSQL, and Oracle, and third-party drivers also allow others to be used. It provides an abstraction layer that eliminates the need to write SQL queries to get/save data to the database. The features of Django are its authentication, URL routing, template engine, object-relational map mapper (ORM), and database schema migration (Django v.1.7 +).
If you choose Django, you don’t have to worry about a lack of features. You will get everything you expect from this framework: from the template engine to the object-relational mapping. And most importantly, it is free and open-source.
Flask is a microframework, and therefore more attention is paid to the simplicity of work and the ability to quickly build the necessary web service. It takes much less time to configure and install than other frameworks; HTTP functions are available with lower levels of abstraction. Flask was inspired by the Sinatra Ruby framework. Flask’s core idea is to help build a solid foundation for web applications. It has a number of useful functions: built-in development server and fast debugger, Jinja2 templating, support for secure cookies, and the ability to connect any ORM. It is suited for both beginner web developers and experts who want to use best practices, achieve rapid prototyping and create stand-alone applications.
Bottle is a very lightweight framework and fits in just one file. Despite its minimalism, Bottle provides quite ample functions and is 100% enough for small and medium-sized projects.
It includes routing for clean URLs, and templates are a strong point of this framework. Utilities (i.e. “bottles”) provide convenient access to data forms, file uploads, headers and other metadata related to HTTP. It has a built-in HTTP development server that supports the functions fapws3, bjoern, GAE, CherryPy and any other HTTP server that supports WSGI.
This is an almost perfect solution for prototyping, learning how to organize web frameworks, and creating simple applications.
New web frameworks
We will now go through a brief summary of some Python web frameworks in order to have an idea of what new solutions are available. Any new framework needs to be treated with attention and respect. For starters, it is recommended that you try a new framework on a pilot project, study its pros and cons, step on a couple of rakes and only then use it in a commercial project for the client.
One of the new web frameworks for Python 3.5+ positions itself simultaneously as a web server and web framework, which is very convenient if you need to quickly deploy a project. In Python 3.5, there is a new opportunity to use async /await to build asynchronous programs, and Sanic skillfully uses this opportunity. This is probably by far the easiest and most convenient method for a fast and scalable web server and integrated web framework for Python. This framework supports convenient work with routers, a variety of formats (and of course JSON) and versioning, exception handling, web sockets, streaming and much more. Additionally, it is freely accessible on the GitHub.
Starlette positions itself as a lightweight framework or toolkit with very high performance. This framework is based on the Asynchronous Server Gateway Interface (ASGI) and can be used as its toolkit. At the same time, WebSocket, GraphQL, Session and Cookie are supported. The developers declare the absence of a rigid binding to other solutions (Zero hard dependencies) and give a guarantee for 100% test coverage and 100% type annotated codebase. This is very important if your project requires reliable execution and you are demanding on the components on which your system is built. The framework requires Python 3.6+ to install and work. You will also need to install an ASGI server, such as uvicorn, daphne, or hypercorn.
Masonite is the new web framework for Python, and is positioned as one of the best frameworks created for developers. The creators of this framework insist on its improved extensibility, which essentially turns this solution into an excellent framework for all kinds of additional features t for your project in the future. It is ideal for novice developers, but it can be useful for experts in this field. Masonite has a simple routing mechanism. It is possible to use Active Record ORM. The framework already works with Python 3.4+ using the Latest version of OpenSSL and Pip3.
If the main task in your project is supporting OpenAPI, then you can use the fast and reliable FastAPI framework. According to the developers, the speed of FastAPI is comparable to NodeJS and Go.
In addition, the framework immediately provides automatic interactive documentation. It uses Python 3.6+, Starlette for the web parts, Pydantic for the data parts,s and uvicorn for the server that loads and serves your application.
Responder is based on Starlite for reasons already known to you and allows you to build an ASGI application with a pre-installed working static file server using the jinja2 template engine (without additional import). To work with the webserver, uvloop is used, with the ability to automatically process requests with gzip compression.
The authors describe this framework as combining two successful approaches from Flask and Falcon. It uses the Flask-style route expression, and on the other hand, uses the Falcon's methodology "every request and response is passed into each view and mutated". It is important that the built-in testing client comes with the framework.
Molten is a minimal, extensible, fast and productive framework for building HTTP APIs with Python. Molten’s features that can be highlighted: automatic validation of requests according to predefined schemas, dependency injection, support for function-based middleware, configuration files, Prometheus metrics, request ids, sessions, SQLAlchemy, templating, WebSockets and more. Also Molten is type-safe. The project is well documented and supported by authors.
Klein is a micro-framework for developing production-ready web services with Python. It’s built on widely used and well-tested components like Werkzeug and Twisted. Klein has a minimalistic API, which is similar to Bottle and Flask, for which developers respect it. It does not depend on third-party libraries. Klein also supports async and await keywords that are available in Python 3.5+. Klein also supports uniform error-handling code for many routes.
This is a very interesting framework, as it supports Flask applications and Asyncio asynchronous calls. This combination makes it possible to use the already established approach to the popular Flask framework and the modern programming mechanism from Python 3.5. Quart supports Flask Extension and works with video and Websockets. There is a standard migration technique with Flask. Quart supports the full ASGI 3.0 specification. Testing is supported by Tox.
Inspired by Flask, ASP.NET Core, BlackSheep is an asynchronous web framework to build event-based, non-blocking Python web applications. Also, BlackSheep provides a ready-to-start MVC project template. To run an application BlackSheep uses the methods provided by the ASGI HTTP Server, i.e. uvicorn.
BlackSheep has automatic bindings and dependency injection and provides a strategy for handling authentication and authorization. This high-performance framework keeps the core package minimal and focused, as much as possible, on features defined in HTTP and HTML standards. It allows developing stateless applications to be deployed in the cloud.
Twisted is an event-driven network programming framework for Python, and Cyclone uses it for building Tornado API for web framework. Cyclone is the most stable and reliable web framework with non-blocking I/O. It provides httputil for the manipulation of HTTP headers and URLs. Cyclone has internationalization support, inline SQLite, non-blocking Redis client, third-party login with OpenID and OAuth, XML and JSON encoded Remote Procedure Calls, and many other features.
Pyramid is an open-source Python web framework. Its main goal is to build web applications with minimum complexity.
Pyramid designed to work well with both small and large applications. Pyramid’s features include a possibility to build single-file applications, use all-embracing templating and asset specifications, flexible authentication and authorization. It has great testing, support, and comprehensive data documentation. Pyramid provides function decorators, predicates and renderers.
In the modern world, it is very difficult to predict which of these frameworks will replace the old and good Django, Flask, and Bottle. But technologies are developing and improving, especially regarding web frameworks for Python. As a result, we will get more accurate and efficient web application development frameworks with new and improved features.
Python has taken its reliable niche among the languages for web development and the trend is only increasing every year. The new frameworks help to consolidate this technology within the industry, We will soon know which of these new frameworks will become mainstream.
Let's discuss your project
We look forward to learning more and consulting you about your product idea or helping you find the right solution for an existing project.
Your message is received. Svitla's sales manager of your region will contact you to discuss how we could be helpful.