Top 10 Python Web Frameworks

Top 10 Python Web Frameworks
When you want to make a website, you need HTML, JavaScript and CSS. To create a website using Python, you need a few other things. These things are ways to create HTML, CSS and maybe even JavaScript. You could create routines to write each web-page as users interact with the site and other events occur. This is exactly what the authors of web frameworks have done, making it easy to create pages and entire sites. Calling it easy is an exaggeration but at least it will help to make the process faster.

What types of web frameworks are there?

Since the developers of each framework had different needs, the frameworks differ between them. Some wanted to quickly solve the single problem they had and others wanted a more full solution.

A micro framework is built to have very little functionality from the start so you can add as your needs grow. Other frameworks are so full of functions from the start that you have a functioning site as soon as you have installed the basics. These ones usually work as a content management system from scratch, something you may or may not want.

What do you want to create?

When you choose your framework, you should first consider what you want to create and choose accordingly. As mentioned earlier, you may want a CMS and just put your own spin on it or you have something more unique in mind. Make a plan for your site and try to find the framework you need for that particular task. If you want to learn, pick one that has very few functions first as it will teach you more. If you pick a more advanced one, a lot of things will already have been done for you. Less effort and less learning or more effort and deeper knowledge in the end, your choice.

What will you learn about each framework?

In this article, you will learn which framework works best for you based on this list of frameworks below:

Django

Django is a well-known framework that includes a lot of things. When you start using it and run the initial script it sets up all code so it works. Your next step is to clear out stuff you do not want and add what you do want. All files that are needed are created by the initial script and all you have to do is edit them to adapt to your own needs. Many databases are supported and it also has an object relational mapper(ORM). An ORM is useful because you can design your databases once and stick with it even when you switch databases.

Flask

Flask is micro web framework, this means it has very few functions in the beginning. You also have to create your file structure yourself. This is more work but also means more control. There are many plug-ins so this framework being micro does not make it limited. It just needs a little more attention when you start building a new project. Databases are not built-in but you have several great plug-ins available at their own site. As with most of the web frameworks, you can also have a local web server running as you code, for debugging purposes.

Web2Py framework

Web2Py runs as is when yo have it installed, it comes with a built-in administrative interface and can run locally without any install procedure. It is written in Python and designed to be programmed with Python. This framework also has plug-ins like the others, however this one also has ‘recipes’. These recipes is all the code for a finished site that you can download and adapt to your own needs. With this package you can download one other package and have a full website running. One example is www.tinywebsite.net, you can use the GitHub code for web2py, go to your applications directory and clone the tinywebsite into that directory and you have aworking website.

TurboGears

TurboGears has an interesting concept, you can start this package as a micro framework or add before you start. This means that you can move into a full stack solution from a micro framework. The minimal mode actually needs only one source code file from you to run, allowing you to choose exactly how much control you have as you grow. In the full mode, it supports many databases and has a comprehensive template system. To try it out, just install it in a virtual environment using pip.

CubicWeb

The cubicweb framework has a simple interface with almost all application logic in ‘cubes’, these are extensions. When you start using it, you are well advised to pick a ‘cube’ and see what you want to change in it. CubicWeb installs like a normal application in Debian based applications, just add their repository and install. There are two packages; the run time and the development package. This framework relies heavily on object oriented programming in Python so if that is your fancy, take a closer look. The connection to databases are made through their own query language, named RQL which is similar to W3C’s SPARQL. If this sounds good to you, they have 190 ‘cubes’ to help you create great websites.

Sanic

The Sanic framework was developed with speed as first hand priority, it allows async/await which was added in Python 3.5. Sanic supports Python 3.6 and higher! You install sanic with the pip command. The other aim is to be simple, you can get one ‘Hello World’ started in ten lines of code. To get full use of this framework, you need uvloop and ujson, it will work anyways but the intended speed will not be realised. Sanic is easy to run directly as a web-server while still using it for developing your web site.

Giotto

Giotto is designed to have very small codebase while still having most functions. You install Giotto with the pip command. To try it out and start experimenting, you only need three commands. The project uses Jinja2 for HTML templates, SQLAlchemy for database connection and supports Redis for cache handling. To install Giotto, use the pip command, the most recent version is on GitHub. You can use the git extension of the pip command to get it. To create the file structure for a new project you run the ‘giotto create’ command this creates the whole file structure for you to adapt to your needs.

Pyramid

The Pyramid started life as the Pylons Project, the ambition is and has always been a balance between micro framework and full stack solution. It too aims to be small and scale easily. One original idea is that there is no extension system, instead you create and use extensions on the PyPi system. This makes it flexible to make a new add-on.

Bottle

Bottle is distributed as a single file module and requires only Python itself. It is very small and has a built-in template engine and development. Despite that it has support for the other template engines and any WSGI capable server available. You can use their recipes to get an idea of how to use the framework, feel free to use these in your own code. Bottle has many plugins, however not as many as other projects.

CherryPy

CherryPy prides themselves of having made a powerful configuration system. The system is also extremely easy to get started with since developers do not need to learn about all the modules. This makes it seem like you cannot use it for bigger systems but that is incorrect. Netflix uses this framework.

Conclusion

You have many choices when you choose a framework for your next web project. Take some time to consider what you need before you start. However, there are so many, you have to put a time limit on your research and get started with one only.

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *