Quiz: How a Web App Works¶
Test your understanding of the browser front end, the back-end server, requests, status codes and webhooks with these review questions.
1. In a web application, what is the back-end server?¶
- The screens and buttons that run inside the member's browser
- The outside services the app calls, such as image search
- Code that runs on a computer the builder controls, receives requests and sends back answers
- The folder on the builder's laptop that holds the code
Show Answer
The correct answer is C. The back-end server runs on a machine the builder controls. It receives requests from browsers, does the work and answers. In the dating-safety app it is an Express server hosted on Railway. Option A describes the browser front end. Option B describes vendors the back end calls. Option D describes the codebase, which holds both halves.
Concept Tested: Back-End Server
2. What is a webhook?¶
- An HTTP request an outside service sends to your server when something happens on its side
- A request your server sends to a vendor every few seconds to ask for news
- A browser setting that blocks requests from unknown sites
- A short label in a request that says which member is signed in
Show Answer
The correct answer is A. A webhook is the diner's buzzer. You give a service such as Stripe the address of an endpoint, and Stripe calls it when a payment succeeds, so your app hears about it without asking. Option B describes polling, the "has she paid yet?" approach webhooks replace. Option D describes a header.
Concept Tested: Webhook
3. Which family of HTTP status codes means the server failed while trying to handle the request?¶
- 2xx
- 3xx
- 4xx
- 5xx
Show Answer
The correct answer is D. A 5xx code says the server failed while trying. A 4xx says the client sent something wrong, such as no sign-in or a thing that doesn't exist. A 2xx means it worked, and a 3xx means the thing is somewhere else. The 4xx and 5xx split is the most useful one to remember, because it tells you whether to look at the request or at the server.
Concept Tested: HTTP Status Codes
4. What does the HTTP method in a request tell the server?¶
- Which member sent the request
- What kind of action the client wants done, such as read or delete
- Which server the request should go to
- What format the body is written in
Show Answer
The correct answer is B. The address says what thing, and the method says what to do to it. GET /api/scans/4821 reads a scan, while DELETE /api/scans/4821 destroys it. That's why one path can need different locks for different methods. Options A and D are carried in headers, and the server is named by the URL's host, so C is also wrong.
Concept Tested: HTTP Methods
See: HTTP Methods
5. Why must every check that protects a member run on the back end instead of the front end?¶
- Back-end code runs faster than front-end code
- The front end runs on a device the member controls, so anyone can change it or skip it
- Front ends can't read JSON
- Browsers block front-end code from checking sign-in
Show Answer
The correct answer is B. Everything in the front end runs on the member's own phone or laptop. Anyone can change that code or send a hand-made request that skips it, for example with curl. So the back end must treat every request as a stranger at the kitchen door. Speed (A) is beside the point. Front ends read JSON all the time, and browsers don't block sign-in checks.
Concept Tested: Client and Server
6. The finished scan's JSON includes a field the results page never shows. Why does that matter?¶
- It doesn't matter, because hidden fields are encrypted
- It slows the page down, which is the main risk
- It breaks the REST pattern, so other endpoints stop working
- Anything in the JSON reaches the member's browser, whether or not the page shows it
Show Answer
The correct answer is D. The JSON is the app's answer, and the screen is only one way of showing it. Anyone can open the browser's tools and read every field. If the JSON carries a location or another member's data, it has leaked even though the page hides it. Hidden fields are not encrypted (A), and the issue is exposure, not speed or REST style.
Concept Tested: JSON
7. Dana changes the scan number in a request to 4822, which belongs to another member. Why does the dating-safety app answer with 404 instead of 403?¶
- A 403 would confirm that scan 4822 exists, which is itself a leak
- A 404 is faster for the server to send
- Browsers can't show a 403 page
- A 404 tells Dana to sign in again
Show Answer
The correct answer is A. A 403 says "this exists, and you can't see it." That tells a curious member which scan numbers are real. A 404 gives the same answer as for a scan that was never created, so nothing leaks. Speed (B) is not the reason. Browsers show 403 pages fine. Asking someone to sign in is the job of a 401, not a 404.
Concept Tested: HTTP Status Codes
8. Two versions of a "Delete account" route look the same on screen. Version A deletes whichever account number arrives in the request. Version B deletes the account of the member the server knows is signed in. What should you tell your agent?¶
- "Keep Version A, but hide the button from members who aren't signed in."
- "Keep Version A, but check the account number in the front end first."
- "Use Version B: take the member from the server's sign-in, never from the request."
- "Either version is fine, since both pass a click-through test."
Show Answer
The correct answer is C. In Version A, anyone can send a hand-made request with someone else's account number and delete that account. Hiding the button (A) or checking in the front end (B) doesn't help, because a hand-made request skips the front end entirely. Passing a click-through test (D) proves nothing here, since normal use only ever sends the member's own number.
Concept Tested: Back-End Server
9. Your agent wants to run git push --force, npm test and ls. Which command deserves a pause before you approve it?¶
ls, because it lists every file, including secretsnpm test, because tests can change the live databasegit push --force, because it can overwrite saved work on GitHub- None of them, since agents only suggest safe commands
Show Answer
The correct answer is C. git push --force can overwrite saved work on GitHub, which makes it a one-way door. The chapter also flags rm -rf, DROP TABLE, migrations against the live database and anything that prints .env. ls only lists file names, and npm test runs the test suite. Option D is wrong: agents suggest risky commands too, and reading a command before you approve it takes seconds.
Concept Tested: Terminal and Command Line
10. The server crashes halfway through a scan and sends a 500, but the front end ignores the code and draws an empty results page. Which product rule is now at risk?¶
- No false all-clear, because an empty page can read as "nothing found"
- Never reveal a location, because a crash exposes addresses
- Shared reports need a code, because the 500 skips it
- None, because a 500 always shows an error screen on its own
Show Answer
The correct answer is A. A front end that draws whatever it got can show an empty results page after a crash. A member could read that as "no problems found," which is a false all-clear. The fix is to have the front end check the status code and say plainly that the scan failed. A crash doesn't by itself expose a location (B) or skip a share code (C). Browsers don't show an error screen on their own (D).
Concept Tested: HTTP Status Codes