“6 Best Python Web Frameworks to Learn in 2018”

Post Image

A web framework is a so-called library that makes a developer’s life easier when building web applications. Most popular web frameworks encapsulate what developers across the globe have learnt over the past twenty years.

Most of you, when choosing a framework for a web application, firstly think of Django. No doubt, in lots of cases Django, with its everything-out-of-the-box and (killer feature) automatic database generation, is very suitable.

However, let's take a look around. There is a number of various Python frameworks and, surprisingly, they aren't clones of Django. Some of them are surely better to choose, or at least worth learning, for some specific usage.

There are more than 25 active Python web framework projects. Projects without stable releases during the last 365 days and web frameworks not supporting Python 3 were left out.

Let's develop a very simple application with each popular framework. An application must response "Hello world!" to /hello/ request, and also templating must be used to pass "Hello world!" message dynamically. Database access is another important question regarding frameworks, but comparison of that would be too bulky for such brief overview. For API frameworks (Falcon, Hug and Sanic) a response must be {'message': 'Hello world!'}.

1) Django

The main principle of Django ninjas is to develop everything of any complexity IN TIME. It's originally developed for content-management systems, but its rich features including but not limited to templating, automatic database generation, DB access layer, automatic admin interface generation - are well suitable for other kinds of web applications. Provides a web server for development use. Form serialization and validation, template system with inheritance of templates, caching in several ways, internationalization, serialization to XML or JSON. Django is contributed with applications for maintenance: an authorization system, a dynamic admin system, RSS and Atom generators, Google Sitemaps generator, and so on. Django is used by Instagram, Pinterest, The Washington Times, Disqus, Bitbucket and Mozilla.

When developing a microapplication, Django begins with complexity from the start. After installing the package (Django, literally), you must create a project with "django-admin startproject myproject" command. Then, you should configure the app in myproject/myproject/settings.py - at least database access and templating. Django application is always unified in structure. It's excellent when you develop many boring applications.

2. Flask

A microframework for Python based on Werkzeug and Jinja2 "with good intentions". Being a microframework, Flask is worth using when developing small applications with simple requirements, not like Django, Pyramid, et cetera. For example, you may operate your database in any way you like with Flask - by means of SQLAlchemy or anything else. Use it if you are going to develop a small application and configure everything by yourself. Other features: development web server, integrated unit testing support, Google App Engine compatibility. Flask is used by LinkedIn, Pinterest.

3. Tornado


Its main feature is non-blocking I/O. Thus, Tornado can be scaled to handle tens of thousands of open connections. An ideal framework for long polling, WebSockets and other usages with continuous connection. Tornado officially supports only Linux and BSD OS (Mac OS X and Microsoft Windows are recommended only for development use). The origin of Tornado is FriendFeed project, now owned by Facebook.

The task doesn't need any of the Tornado's key features - asynchrony. By the way, simple applications with Tornado are easy.

4. Falcon

Falcon is a microframework for small applications, app backends and higher-level frameworks. It encourages to follow the REST concept, and thus, you should think of resources and state transitions mapped to HTTP methods when developing with Falcon. Falcon is one of the fastest web frameworks in Python. It's used by Cronitor, EMC, Hurricane Electric, OpenStack, Opera Software, Wargaming, Rackspace.

Falcon is not suitable for serving HTML pages at all. It is appropriate for RESTful APIs. Here is some code to response for a GET request with a JSON response.


One of the fastest web frameworks for Python. It's designed to build APIs. It supports providing of several API versions, automatic API documentation and annotation-powered validation. Also, hug is built on top of another JSON framework which is Falcon. Let's provide a JSON response via hug.

6. Sanic

A Flask-like web framework which is developed to be fast. It supports asynchronous request handlers, making your code non-blocking and speedy.


Add Comment

You May Also Like