Python web programming – introduction


Lesson 1 of 14 · Python for the web

Python is not only a language for scripts and data analysis – today it is one of the most popular languages for developing web applications.

Large platforms such as Instagram, Pinterest and Dropbox use Python for the backend development of their systems.

Web programming means building applications that run on a server and that users reach through an internet browser.

In this course we will learn how to use Python to build web applications with modern frameworks such as Flask and Django.


How does a web application work?

To understand Python web programming, we first have to understand the basic structure of a web system.

Every web application consists of three basic parts:

  • Frontend – the HTML, CSS and JavaScript the user sees
  • Backend – the server program that processes the data
  • Database – the place where the information is stored
An example of communication in a web application
User → Browser → Server (Python application) → Database → Server → Browser

Python is used exactly in the backend part, where it processes the users' requests and returns the result to the browser.


What is a web framework?

Writing a complete web application from scratch would be very complicated.

That is why we use a framework.

A framework is a set of libraries and tools that make developing applications easier.

The most popular Python web frameworks are:

  • Flask – a simple and light framework
  • Django – a powerful framework for large applications
  • FastAPI – a modern framework for API services

An example of a simple Python web application

Let us look at the simplest example of a web application in Flask.


from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from the Python web server!"

app.run()

This program starts a small web server that shows the text when we open the application's address in the browser.

If you run this program and open the browser, you will see the message the server returns to the user.

Why learn Python web programming?

Python web development is very popular because it makes it possible to build applications quickly.

  • simple syntax
  • a large number of libraries
  • a large community of programmers
  • suitable for beginners
  • used in industry
If you already know the basics of Python, you can very quickly start building real web applications.

What will we learn in this course?

In the following lessons we will learn:

  • how the HTTP protocol works
  • how Python communicates with the browser
  • how to use the Flask framework
  • how to make the first web application
  • how to use HTML templates
  • how to connect a database
  • the basics of the Django framework

Mini projects in this course

  • the "Hello world" web application
  • a to-do list
  • a mini blog
  • a simple API service

Where is Python web used?

  • social networks
  • web services
  • online shops
  • blog platforms
  • API services

Related lessons


Frequently asked questions

Do I have to know HTML for Python web?

Yes. HTML is used to display content in the browser, while Python processes the data on the server.

What is backend programming?

The backend is the server part of the application that processes the users' requests, communicates with the database and returns the result to the browser.

Is Flask easier than Django?

Yes. Flask is simpler and is often used for learning and for smaller projects.

Can Python build large web applications?

Yes. Many large companies use Python to develop large web systems.