This is a free preview. Enrol on the course to save your progress and open every lesson.

Lesson 2 of 31 · 12 min

Requests, responses and URLs

How a web page reaches you

  1. You type a URL or click a link. Your browser sends a request to a server
  2. The server runs some code (for us: a Python function)
  3. It sends back a response: usually HTML, sometimes JSON or an image
  4. Your browser shows it

Parts of a URL

https://shiftswap.example/shifts/7/claim?from=home

PartExample
Protocolhttps — the S means it's encrypted
Domainshiftswap.example — which server
Path/shifts/7/claim — which page or action
Query string?from=home — extra details

Methods: GET and POST

  • GET — "show me something". Loading a page. Should never change anything
  • POST — "do something". Submitting a form, taking a shift, logging out

Status codes

CodeMeans
200OK
302Redirect — go to another page
400Bad request — something in the request was wrong
401 / 403Not logged in / not allowed
404Not found
500The server's code crashed

Try it

In Chrome or Edge, press F12 to open DevTools and click the Network tab. Reload any website. Each line is one request — click one and find its method and status code.