In many ways, we're living in the golden age of web development. Web technologies have never been as refined and flexible as they are today, and if you want to build a high-quality website or web app, you have so many viable ways to get there -- including the use of Python.

Contrary to popular belief, Python isn't only useful for data processing and utility scripts. Take a peek at HotFrameworks.com and you'll see that the fifth most popular web framework is Python-based. Next to JavaScript and Ruby, Python is one of the best languages to use for web development.

How Python Is Used in Web Development

When developing a web app, Python serves in similar capacity to languages like PHP and Ruby: it's mainly used to handle back-end processing and routing. Web pages still need to be rendered using HTML, the theme is still handled with CSS, and front-end processing is still done in JavaScript.

That may sound overwhelming, but depending on which Python web framework you use, it doesn't have to be as bad as it sounds. For example, Django has a templating system for writing special HTML files that can embed Python code and interact with data from the Python back-end.

View template example from the official Django tutorial

This kind of framework is called a full-stack framework -- one that comes with systems that handle HTTP requests, database storage, web page templates, routing requests, etc. On the other side, you have a non-full-stack framework, also called a micro-framework, that only handle the basic back-end logic and needs to be combined with third-party databases, templating engines, etc.

In general, full-stack frameworks have steeper learning curves and force you to adopt certain conventions and structures, but provide everything you need. Micro-frameworks can be learned in no time and are more flexible, but you may need to re-invent wheels with every new project.

Python vs. Other Web Development Languages

As of this writing, JavaScript frameworks like React are soaring in popularity, particularly among newbie web developers. The line of thought goes: "If I need JavaScript for the front-end, why not use JavaScript for the back-end too?" That makes sense. And PHP has been around for decades with lots of documentation, so it's also a viable option.

At the end of the day, use whatever language you want to use. Anything you can make with one language can be made with another -- all that really matters is how comfortable you are using it. If a language isn't a good fit for you, you'll just be frustrated and quit. But here's why I love Python:

  • Python is clean and easy to learn. Both JavaScript and PHP are "programmery" (e.g. lots of braces, weird syntax, etc.) and come with all kinds of baggage that can lead to messy and unmaintainable code. Python is one of the easiest languages to learn and doesn't feel like a programming language. It's also compact -- you can write a lot of logic in a few lines of code.
  • Python web frameworks are less fragmented. JavaScript has dozens of oft-used frameworks: Backbone, React, Vue, Angular, Knockout, Ember, Meteor, etc. Python also has a lot of frameworks but only a few of them are used seriously (see below for examples), so the community isn't as fragmented. PHP has a leg up on Python though, as there's only one viable framework these days: Laravel.
  • Python is a general purpose language. JavaScript is mostly limited to two pursuits: web development and mobile app development. PHP is even more restricted, only able to be used for back-end web development. Python is vastly more flexible, which means you can take your expertise with you if you ever move on from web development.

To get started in Python web development, you should seriously consider using one of the following. They're all robust with a significant amount of history, so you can rest assured knowing that they are good enough for production use and won't disappear overnight.

Django -- The premier all-in-one web framework for Python enthusiasts. It comes with dozens of built-in components that are all well-tested and guaranteed to work together. You'll have to learn "the Django way" to make web apps, but once you embrace that, rapid development is the norm. And if you want a job as a Python web developer, Django is pretty much the only path.

One thing to note about Django: it's very good at scaling. As your web app grows larger and larger, it will generally be easier to stay organized than if you had used another Python web framework. And Django is open source, in case you're interested in contributing.

Flask -- A micro-framework that only provides enough to get started and gives you full control as to which third-party components you'll integrate. In this sense, it's almost the polar opposite of Django: Flask offers nearly zero opinion in how you should build a web app. It's simple and easy to learn.

This is a double-edged sword. If you know you need to use such-and-such technologies, then Flask can be the minimal glue that holds them all together. If you have no experience, however, you can easily shoot yourself in the foot over and over again in trying to tame Flask.

Pyramid -- You can sort of think of Pyramid as a compromise between Django and Flask. It's nowhere near as opinionated as Django and you'll have more freedom to organize your web app as you wish, but it is somewhat opinionated and isn't as barebones as Flask.

Another way to think of it: Pyramid comes with a lot of default functionality, but makes it easy to override them as necessary. Pyramid has a large library of official and unofficial plugins that you can pick and choose on a per-project basis.

Examples of Sites Using Python

If you've gotten this far and you're still skeptical of Python being used for web development, here are a handful of well-known sites that were created using the above frameworks. What you'll find is that Python is an excellent choice for websites and web apps, whether small, large, minimal, or complex.

Instagram (Made with Django)
Bitbucket (made with Django)
Reddit Gifts (made with Django)
Reddit Gifts (made with Pyramid)
AdRoll (made with Pyramid)
The Daily Climate (made with Pyramid)

Start Using Python for Web Development

Ready to get started but have no Python experience? No worries. Check out our basic examples of Python to see how Python feels and to get a grip on the fundamentals. After that, check out these YouTube programming channels -- in particular, the ones related to Python and web development (look for the ones on Django and Flask).

On top of that, I highly recommend listening to some programming podcasts. There are several that will go hand-in-hand with your journey through Python and web development. I'm especially fond of Developer Tea, a short daily podcast that's motivating and relaxing.

How do you feel about Python? Will you be using it for web development? What kinds of sites or apps do you want to make? Share with us in the comments below!