Frameworks make developers’ lives easier by offering them a structure for application development. They automate the implementation of common solutions, cutting development time and allowing developers to focus on application logic instead of routine elements.
In this article, we share a list of the top twelve Python web frameworks that will be useful on your way to becoming a professional backend developer and improving your existing skill set.
Why Python frameworks? Stack Overflow has recently released the results of their annual developer survey for 2019, which declared Python the fastest-growing major programming language.
By far, the most popular Python frameworks are Django and Flask. But that doesn’t mean you should discount the potential of other frameworks. Each of them possesses features that could be a perfect match for your web project.
Keep in mind that the Python frameworks we’re going to talk about here are not listed in any particular order: we’ve focused on showing what you’re able to do as opposed to telling you what you should do.
For one thing, when deciding which framework to use, look at the size and complexity of your project. If what you’re looking to develop is a large system packed with features and requirements, a full-stack framework might be the right choice. If your app is on the smaller and simpler side, you should probably consider a microframework.
Second, you need to check if the framework you’re considering can scale vertically and horizontally. This is a must for projects that are to run on several servers, handle huge amounts of traffic, and support the addition of new features to enhance functionality.
Once you’ve chosen a framework, contact a team of developers and ask them for information about the estimated cost to develop your app.
You can find information about the type and focus of some frameworks here. A final decision, though, should come from your own understanding of your project and the tasks you want to simplify.
However, frameworks can also stand in the way of development. When choosing a full-stack framework, you’re often signing up for a set of limitations. Of course, you can find ways to work around them, but be careful you don’t spend more time fighting for your own freedom than you would have writing an app in pure Python.
A full-stack framework or an enterprise framework is an all-in-one solution with libraries configured to work seamlessly together. It supports the development of backend services, frontend interfaces, and databases. A full-stack framework provides anything a developer requires for building an application. Python offers more than one full-stack framework.
GitHub Stars: 44,077 | GitHub Forks: 18,949
Django is a free open-source full-stack Python framework. It tries to include all of the necessary features by default as opposed to offering them as separate libraries.
These features make Django highly scalable, ridiculously fast, and extremely versatile.
Django uses its ORM to map objects to database tables. The same code works with different databases and isn’t difficult to transfer from one database to another. The main databases that Django works with are PostgreSQL, MySQL, SQLite, and Oracle, but third-party drivers allow you to use others as well.
With Django, you can craft any web application from small-scale projects to complex websites. Thanks to its flexibility, Django is also used for crafting MVPs, allowing startups to optimize their time and budget.
Django’s user base is expected to grow, as many developers see this framework as the best choice for emerging technologies such as machine learning. Also, in 2020, the Django community is planning to release more libraries to meet the growing demand.
Here at SteelKiwi, we use Django as our primary framework for backend development. If you’d like to see the amazing apps we’ve already developed with Django, visit our Projects page.
GitHub Stars: 3,215 | GitHub Forks: 866
Pyramid is an open-source – and the second noteworthy – Python-basedweb application framework. Its goal is to do as much as possible with minimum complexity. Running on Python 3, Pyramid keeps up with technological improvements. Pyramid 1.10 is the current version of the framework and is the tenth update since 2010.
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
With Pyramid, a developer can decide on the templating language, generation libraries, and database layer.
The Pyramid community is active and boasts many releases. Developers can follow the framework’s progress by joining the official IRC channel or joining Google and Twitter groups.
GitHub Stars: 654 | GitHub Forks: 65
TurboGears is an open-source, data-driven full-stack web application framework. It’s built on lots of middleware and many libraries and was initially crafted to combine the best components of other Python frameworks.
TurboGears allows you to quickly develop extensible data-driven web applications. It comes with a user-friendly templating engine and a powerful and flexible ORM. In addition to great template systems that make designers’ lives easier, TurboGears offers lots of flexibility, strong support of aggregates, a powerful ORM, and reusable snippets.
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
- PasteScript templates
- Front-facing WSGI-based servers (Paste HTTP server, CherryPy WSGI/HTTP server, etc.)
- Command-line tools
- All features implemented as function decorators
As for the future of TurboGears, the community is currently working on improving the framework’s capabilities and overall stability and are about to release the “minimal code.” This code is also referred to as a microframework, or a stripped-down version of TurboGears. The minimal code will help developers build apps faster, saving money and time.
GitHub Stars: 1,794 | GitHub Forks: 818
Web2py is a scalable open-source full-stack Python framework. It’s very powerful when it comes to handling data. Web2py was originally offered as a teaching tool with a focus on ease of use. This explains why there are no project-level configuration files.
What’s great about Web2py, though, is that it comes with its own web-based IDE which, 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
- Error tracking, thorough error logging and ticketing
- Role-based access control
- Support for internationalization
- Backward compatibility that ensures user-oriented advancement without the need to lose ties with earlier versions
A ticketing system is the main feature of Web2py; it issues tickets whenever errors occur. This way, users can track errors and their statuses.
Despite all these advantages, the Web2py community is smaller than Pyramid’s or Django’s. Not many developers are using it. This means the chances of receiving support are lower. Plus, the official mailing list is not very active.
A microframework, or a minimalistic web application framework, lacks most of the functionality of a full-fledged framework such as a web template engine, authentication functionality, accounts, authorization, input validation, and input sanitation. A microframework attempts to provide only the component set required for building an application. It may also focus on providing the necessary functionality for one particular sphere.
Github Stars: 46,475 | GitHub Forks: 12,921
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 is chosen for any and all projects. In fact, it’s a default choice for any web project that isn’t a match for Django.
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 forunit testing
- RESTful request dispatching
- Jinja2 templating
- Secure cookies support (client-side sessions)
- WSGI 1.0 compliance
- Ability to plug in any ORM
- HTTP request handling
Since its launch in 2010, Flask has been updated 27 times. To date, it remains the top growing Python framework. However, many Flask extensions are no longer supported: the documentation is outdated and they’re no longer being developed. If you run into this, you’ll need to Google to find an actively supported plug-in with similar functionality.
GitHub Stars: 6,348 | GitHub Forks: 1,245
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. However, Bottle is a match only if you’re crafting a very small application with at most 500 lines of code and no special requirements.
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
Since 2009, Bottle has been updated 73 times, and now it’s a perfect solution for prototyping, learning the organization of web frameworks, and building simple personal apps.
Any contributions to the Bottle community are accepted via GitHub. Users can also join the Bottle mailing list and blog and follow the latest changes on Twitter. If you’re looking for an additional forum for discussion, join a freenode chat.
GitHub Stars: 1,057 | GitHub Forks: 259
CherryPy is an open-source, minimalist web framework. It makes building Python web applications no different than building any other object-oriented program.
CherryPy is created to be extensible. The framework even offers mechanisms for hook points and extensions.For example, a CherryPy-powered web app is a standalone Python application that embeds its own multi-threaded web server. With its own web server, the extension points include functions outside the request-response cycle, thus adding to the level of CherryPy’s extensibility.
In fact, a CherryPy-powered web app is a standalone Python application that embeds its own multi-threaded web server. CherryPy apps run on any operating system that supports Python (Windows, macOS, Linux, etc.). They can be deployed anywhere you can run an ordinary Python app. You don’t need Apache for CherryPy apps, but you can run a CherryPy app behind Apache just as well as you can run it behind Lighttpd or IIS.
CherryPy isn’t a very limiting framework, as it allows you to use any type of technology for templating, data access, and so on. However, it’s still able to handle sessions, statics, cookies, file uploads, and everything else that a web framework typically can.
- An HTTP/1.1-compliant WSGI thread-pooled webserver
- Simplicity of running multiple HTTP servers at once
- A powerful configuration system
- Aflexible plugin system
- Out-of-the-box tools for caching, encoding, sessions, authentication, static content, and so on
- Built-in support for profiling, coverage, and testing
- Ability to run on Python 2.7+, Python 3.1+, PyPy, Jython, and Android
Despite all its features and advantages, many developers feel that CherryPy’s documentation could use some improvement. Plus, CherryPy could be at least a bit easier to use.
Like most other frameworks, CherryPy has a community behind it that provides assistance to beginners and advanced developers. CherryPy has a mailing list and suggests developers join the framework’s IRC channel or Gitter and Google groups.
GitHub Stars: 1,057 | GitHub Forks: 259
Falcon is a bare-metal Python web API framework for building very fast app backends. The logo of the framework is a falcon, symbolizing how quickly Falcon works.
This framework allows developers to craft cleaner designs and handles most requests. Falcon never restricts developers in choosing libraries for databases and authorization.
Other valuable Falcon features:
- 100% code coverage with a comprehensive test suite
- A highly optimized code base
- Upfront exception handling
- REST-inspired resource classes
- URI templates for intuitive routines
- Easy access via request and response classes
- DRY request processing via middleware components
- Idiomatic HTTP error responses
- Unit testing via WSGI helpers
Falcon ignores useless operations during the development of a web framework. Also, it gives freedom of choice: developers can make decisions that will help them tune and customize implementations freely.
Two more advantages worth mentioning are the availability of extensive documentation and an active community.
GitHub Stars: 5,905 | GitHub Forks: 347
Hug is a Python 3 API development framework. It’s crafted to allow software engineers to develop an API once and then reuse it whenever needed. The Hug framework simplifies API development by offering various interfaces. That’s the main reason why this framework is called one of the fastest in Python 3.
Key features of Hug:
- Support for automatic documentation
- Annotation-powered validation
- Built-in version management
- Compliance with Cython
- Can be used as a Python library
The Hug framework contains as few integrations and as little code as possible, remaining functional and providing great performance. Plus, Hug’s community is currently growing. That’s a sign of the framework's demand and proof that whenever a problem occurs, a developer can find help.
GitHub Stars:4,835| GitHub Forks:256
FastAPI is a modern Python-based framework. It was initially designed to be easy to use for ensuring the best development experience. To date, FastAPI is one of the fastest frameworks for building APIs with Python 3.6+.
The framework took several characteristics from Flask, including its simplicity. The whole framework is built on Starlette and includes most of its features (templates, WebSockets, and GraphQL support).
The FastAPI framework offers:
- Increase in development speed by 200% to 300%
- Reduced errors by 40%
- Less time debugging
- Minimization of code duplication
- Automatic interactive documentation
FastAPI isn’t tightly coupled to any database. However, it supports databases you need. With FastAPI, you are free to structure your project the way you need and even use most of the same files from one of your Flask projects.
The only drawback is its small community. But it’s because FastAPI is a relatively new framework.
An asynchronous framework is a relatively recent type of Python framework. It’s a microframework that enables developers to handle a large set of concurrent connections. Asynchronous frameworks use non-blocking sockets and feed on Python’s asyncio library.
GitHub Stars: 12,780 | GitHub Forks: 1,203
Sanic is a Python web framework built on uvloop and created specifically for fast HTTP responses via asynchronous request handling.
It runs on Python 3.5+. Sanic supports asynchronous request handlers, which makes it compatible with Python 3.5’s async/await functions. This enhances its speed, offering non-blocking capabilities.
Sonic is considered the preferred asynchronous framework in the Python world due to its routing, middleware, cookies, versioning, static files, blueprints, class-based views, and sockets. However, it doesn’t offer database support and templating.
In a benchmark test with one process and 100 connections, Sanic was able to handle 33,342 requests per second, with an average latency of 2.96 ms.
GitHub Stars: 18,292 | GitHub Forks: 5,040
Tornado is a Python web framework and asynchronous networking librarythat focuses on speed and the ability to handle large volumes of traffic.It uses a non-blocking network I/O and solves the C10k issue (meaning that, if configured properly, it can handle 10,000+ concurrent connections).
This makes it a great tool for building applications requiring high performance and tens of thousands of concurrent users.
Tornado’s main features are:
- Built-in support for user authentication
- Real-time services
- High-quality performance
- Python-based web templating 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)
- Support for translation and localization
In terms of popularity, Tornado stands somewhere between Django and Flask. Say you want to write something in Flask or Django because of their features and tools, but you also need much better performance. In this case, you should choose Tornado.
GitHub Stars: 9,856 | GitHub Forks: 1,011
Dash is an open-source Python framework used for building analytical web applications. It’s especially good for Python data scientists who aren’t very familiar with web development.
There are two basic benefits of Dash:
- It allows you to build highly interactive applications using only Python code.
- It makes it simple to use the power of Python tools for manipulating data.
Apps developed with Dash are rendered in the web browser and can be deployed to servers. This also means that Dash applications are inherently cross-platform and mobile-ready.
Dash developers have access to the underlying Flask instance and all of its configurable properties. To extend the capabilities of Dash applications, developers can also use the rich set of Flask Plugins.
The right framework might be all you need to develop a successful project. We really hope that you’ve found an interesting framework in this article. We also have another one, the 17 best Python web frameworks of 2021, if you’re interested in exploring more options.