10 Python web frameworks to work with in 2018
From the translator: today we offer you a translation of an article posted on Hackernoon by SteelKiwi. She develops b2b and b2c software solutions, and she shares her experience gained in the process with her readers.
The frameworks make life easier for the developer by offering various solutions for developing applications and services. They automate the implementation of standard solutions, saving you time. Thus, the developer focuses on the application, and not on routine tasks where creative thinking is not needed.
Skillbox recommends: Practical course "Python-developer from scratch . "
We remind: for all readers of "Habr" - a discount of 10,000 rubles when writing to any Skillbox course on the promotional code "Habr".
This article describes ten Python frameworks that will be useful for both novice developers and professionals. In 2018, the old frameworks were updated, new tools appeared that are worth paying attention to.
Before you begin ...
When you start to choose a framework, estimate the size and complexity of your project. If what you are developing is a large system with a fair amount of functions, then the full-stack framework is what you need. If you are creating a relatively small application or service, then you should pay attention to microfograms.
Information about some frameworks is presented on the pages of Wikipedia . The final decision, however, you must make yourself on the basis of the principles of analysis of your own service or application already announced above.
Django is a free open-source full-stack framework. It allows you to add most of the standard functions as a single package instead of searching for individual libraries.
Among them are such popular ones as authentication, URL routing, data scheme migration, etc.
Django uses ORM to map objects to database tables. The same code works with different databases, so switching from one database to another becomes a simple task. The main databases with which Django works are PostgreSQL, MySQL, SQLite and Oracle. You can add others, but this will require third-party solutions.
Pyramid is an open-source framework that gives maximum opportunities to a developer with minimal time and resources.
The most interesting feature of the framework is working with both large and small applications. Separately, it is worth to highlight such Pyramid functions as
- single-file applications;
- URL generation;
- scalable configuration;
- flexible authentication and authorization scheme ;
- understandable technical documentation .
TurboGears is an open-source full-stack framework for web applications. It allows the developer to quickly create extensible, data-driven web applications. TurboGears comes with convenient templates and a powerful and flexible ORM.
The most important functions of the framework:
- support of various databases;
- SQLObject and SQLAlchemy support ;
- validation for FormEncode ;
- Pylons as a web server;
- command line tools.
And this is a scalable open-source full-stack framework for Python. But before you start working with it, you should remember that it is incompatible with Python 3.
But Web2py comes with its own IDEwhich: it has a code editor, a debugger and a deployment in one click. Among other functions and tools, the following should be highlighted:
- no need to install and configure;
- working on Windows, Mac, Google App Engine, Amazon EC2, and on any hosting that supports Python 2.5–2.7 or Java + Python;
- work with various protocols;
- high level of data security;
- error tracker;
- backward compatibility, which allows you to easily work with applications and services based on previous versions of the framework.
This is a microfamir which is licensed under BSD license. Its developers were inspired by the Sinatra Ruby framework. It depends on the Werkzeug WSGI toolkitand the Jinja2 template.
Flask has a modular design that allows you to adapt it to perform many tasks. Out of the box, the developer receives the following functions:
- built-in server and debugger;
- Jinja2 templates;
- secure cookie support;
- WSGI 1.0;
- ability to connect to any ORM.
A framework was created to support web application developers who were able to choose extensions to their liking.
Another microfreemv, which was originally intended to create an API. Bottle is distinguished by the presence of a single source file. Work with him does not require "dancing with a tambourine."
Its default functions include routing, patterns, utilities, and basic abstraction according to the WSGI standard:
- routing supports functional call display requests, allowing you to get clean and dynamic URLs.
- templates are many useful tools that work out of the box with full support for mako, jinja2 and cheetah.
- Utilities - convenient access to data, download files, cookies, headers and other metadata associated with HTTP.
- built-in HTTP development server that supports fapws3, bjoern, GAE, CherryPy, and any other WSGI HTTP server.
This is an excellent solution for prototyping, studying the structure of web frameworks and creating small applications.
CherryPy is a minimal open source web framework. It provides the ability to create Python web applications that are no different than building any other object-oriented program.
In fact, this web application running under CherryPy is a standalone Python application using its own multi-threaded web server. CherryPy applications run on any operating system that supports Python (Windows, MacOS, Linux, etc.). They can be deployed in any environment where you can run a regular Python application. You do not need Apache for CherryPy applications, you can run the CherryPy application in Apache, just like in Lighttpd or IIS.
CherryPy allows you to use any type of technology for templating, accessing data, etc. It can also handle articles, statics, cookies, upload files and everything else that other frameworks can do.
His distinctive abilities:
- simple start of several HTTP servers at the same time;
- powerful configuration system;
- flexible plugin system;
- Out-of-box capabilities: caching, decoding, sessions, authentication, static content, etc .;
- the ability to work under Python 2.7+, Python 3.1+, PyPy, Jython and Android.
Sanic - Python-framework, which is built on uvloop and designed for quick processing of HTTP requests.
It works on Python 3.5+. Sanic supports asynchronous request handlers, making it compatible with the async / wait functions of Python 3.5. This greatly increases the speed of work.
In the benchmark, when processing 100 connections, Sanic showed the ability to process 33,342 requests per second.
Tornado is a Python web framework and asynchronous network library at the same time. It uses non-blocking network I / O and solves the C10k problem (this means that if configured correctly, it can handle 10,000+ simultaneous connections).
All this makes it a great tool for creating applications that require high performance and work with tens of thousands of users at the same time.
- built-in support for user authentication;
- real-time services;
- high performance;
- python-based web template language;
- non-blocking HTTP client;
- implementation of third-party authentication and authorization schemes (Google OpenID / OAuth, Facebook Login, Yahoo BBAuth, FriendFeed OpenID / OAuth, Twitter OAuth);
- translation support and localization.
Dash is an open source Python framework used to create analytical web applications. It is especially good for big data specialists who are not very familiar with web development.
Dash applications are web servers that launch Flask and exchange data with JSON packages over HTTP. Their interface provides components with React.js capabilities.
Applications developed with Dash are displayed in a web browser and can be deployed on servers. Dash applications are cross-platform in nature.
As a conclusion, we can say that developers are really offered a lot of frameworks. Each of them gives its own unique features. But choosing a framework is an important decision for the future of your own project, and you should not rush into it.