Front end and back end
Introduit| English | Sens |
|---|---|
| server/ˈsɜːvə/ | serveur |
| request/rɪˈkwest/ | requête |
| response/rɪˈspɒns/ | réponse |
| front end/frʌnt end/ | front-end |
| back end/bæk end/ | back-end |
| API/ˌeɪ piː ˈaɪ/ | API |
| JSON/ˈdʒeɪsn/ | format d'échange de données |
885 million documents behind a changed number, 2019
- In May 2019 the journalist Brian Krebs reported that the US title-insurance company First American had left about 885 million records — bank details, tax documents — reachable online. A customer's link contained a document number; changing the number showed other people's documents, because the server never checked who was asking.
- Every web app sends a request 请求 to a server 服务器 and receives a response 响应. The server must decide what each user may see.
What went wrong at First American in 2019?
Difficulté 1/5 · 100 pièces + un petit bonus lors de la première réussite aujourd'hui
Changing a number showed others' records.
Front end and back end
- The front end 前端 runs in the browser or app: pages, buttons, forms. The back end 后端 runs on the server: business rules, the database, security checks.
- Anything in the front end can be changed by the user, so security checks belong in the back end.
Match each job to front end or back end.
Difficulté 2/5 · 140 pièces + un petit bonus lors de la première réussite aujourd'hui
Security belongs on the server.
APIs
- An API 应用程序接口 is an agreed set of requests a program can make: for example
GET /api/courses/42asks for course 42. - The response has a status code — 200 OK, 401 not logged in, 403 not allowed, 404 not found — and usually a body.
Match each status code to its meaning.
Difficulté 2/5 · 140 pièces + un petit bonus lors de la première réussite aujourd'hui
Codes tell the front end what happened.
JSON
- Most web APIs send data as JSON 数据交换格式: names and values in braces, such as
{"id": 42, "title": "Databases", "places": 30}. - JSON is plain text, so both front end and back end in any language can read it.

One request, different server and browser states
A valid ID is not permission. Compare a confirmed empty list with a denied request, a failed lookup and a missing response; the interface must preserve these differences.
Which is valid JSON?
Difficulté 1/5 · 100 pièces + un petit bonus lors de la première réussite aujourd'hui
Names and values in braces, names in double quotes.
Worked example: one request, two checks
A student's app sends GET /api/grades/1057.
- Identity: is there a valid login token? No → 401.
- Permission: is student 1057 this user, or is the user their teacher? No → 403.
- Selection: return only the fields needed — module and grade, not the whole student record — as JSON with 200 OK.
A logged-in student asks for another student's grades. Which status code fits?
Difficulté 1/5 · 100 pièces + un petit bonus lors de la première réussite aujourd'hui
Logged in, but not allowed.
Requests take time
- A response can be slow or fail. The front end shows a loading state, then the data or a clear error message.
- Never assume the network always works.
A front end should show a loading state and handle errors.
Difficulté 1/5 · 100 pièces + un petit bonus lors de la première réussite aujourd'hui
Networks are slow or fail.
Hiding a button is not security. First American's links "looked" private; anyone could change the number. The server must check permission on every request.
Hiding a button in the front end stops users reaching the data.
Difficulté 1/5 · 100 pièces + un petit bonus lors de la première réussite aujourd'hui
They can send the request directly.
The front end sends requests through an API; the back end checks identity and permission, then returns a response with a status code and JSON data — only what that user may see.
A timetable app requests GET /api/timetable/88. Describe the checks the server should make and what it returns.
Identity, permission, selection.