Front end and back end
Introduzido| English | Significado |
|---|---|
| server/ˈsɜːvə/ | servidor |
| request/rɪˈkwest/ | solicitação |
| response/rɪˈspɒns/ | resposta |
| front end/frʌnt end/ | interface frontal |
| back end/bæk end/ | interface traseira |
| API/ˌeɪ piː ˈaɪ/ | API |
| JSON/ˈdʒeɪsn/ | formato de troca de dados |
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?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
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.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
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.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
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?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
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?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
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.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
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.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
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.