37. HTTP Methods and Status Codes (HTTP Methods & Codes)
The meaning of GET, POST, 200, 301, 403, 404, 500
Real-life analogy
Think of a restaurant: GET is looking at the menu card, POST is ordering food, and 404 is the waiter saying 'Sorry, this dish is finished!'
Explanation
1. Main HTTP methods:
GET: Retrieving data from the server.POST: Sending new data to the server.
2. Main status codes:
200 OK: Successful301 Moved: Page permanently moved403 Forbidden: No permission404 Not Found: Page not found500 Server Error: Server faultGolden rules
- Always use POST in a login form.
Common mistake
Getting confused between 404 and 500 errors. 404 is the user's mistake, 500 is the server developer's mistake.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px; text-align: center;">
<div style="padding: 20px; border: 2px solid #ef4444; border-radius: 8px; background: #fef2f2; max-width: 280px; margin: auto;">
<h1 style="color: #dc2626; font-size: 32px; margin: 0;">404</h1>
<h4 style="color: #991b1b; margin: 4px 0;">Page Not Found</h4>
<p style="font-size: 11px; color: #7f1d1d;">The requested page does not exist on the server.</p>
</div>
</body>
</html>
Quick quiz
When a file or page is not found on a website, which error code does the browser show?
- 200
- 301
- 404
- 500
Show answer
Answer: 404
404 Not Found means that the requested page does not exist on the server.