Course outline · 0% complete

0/27 lessons0%

Course overview →

Websites, apps, and where code runs

lesson 7-2 · ~10 min · 23/27

What a web page is made of

The response a browser receives (lesson 7-1) is mostly text in three languages, each with one job:

  • HTML describes the content and structure: this is a heading, this is a paragraph, this is a button
  • CSS describes the appearance: colors, sizes, layout
  • JavaScript is a full programming language, like Python, that runs inside the browser and makes the page interactive

So one product involves code running in two places. Code running on the user's device (the browser rendering HTML/CSS and running JavaScript) is called the frontend. Code running on the server (checking passwords, reading the database (the server's organized, searchable store of saved data — accounts, posts, orders), deciding what data to send back) is called the backend. Backends are written in many languages, and Python is one of the most popular choices.

A "web app" like your email inbox is just a website whose frontend and backend do a lot. Most phone apps are the same picture: a frontend on the device talking to the same kind of backend.

Code exercise · python

A tiny taste of backend thinking: this pretend server decides how to respond to one request. Run it, then change the request to "GET /missing" and run again.

Quiz

You click Like on a post and the count updates for everyone who views it. Where did the count change have to happen?

Code exercise · python

Your turn. Extend the pretend server: request is "GET /about". Print "200 OK: About us" when the request is GET /about, keep the GET /home branch from before, and keep 404 Not Found for anything else. Use if/elif/else from lesson 4-3.