dev-tools / http.html
natep2234's picture
Upload http.html with huggingface_hub
d58086e verified
Raw History Blame Contribute Delete
10.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTTP Status Lookup — dev.tools</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: #0a0a0a;
color: #c8c0b0;
font-family: 'Courier New', Courier, monospace;
min-height: 100vh;
padding: 2rem;
line-height: 1.6;
}
h1 { font-size: 1.8rem; color: #d4a54a; margin-bottom: 0.3rem; }
.subtitle { color: #665e50; font-size: 0.85rem; margin-bottom: 2rem; }
input[type="text"] {
width: 100%;
max-width: 400px;
background: #141414;
color: #c8c0b0;
border: 1px solid #2a2520;
border-radius: 4px;
padding: 0.7rem 1rem;
font-family: 'Courier New', Courier, monospace;
font-size: 1.1rem;
outline: none;
margin-bottom: 1.5rem;
}
input:focus { border-color: #d4a54a; }
input::placeholder { color: #44403a; }
.result { margin-bottom: 1.5rem; }
.status-line {
font-size: 1.4rem;
margin-bottom: 0.5rem;
}
.code { font-weight: bold; }
.code-1xx { color: #7a9cc6; }
.code-2xx { color: #a3be8c; }
.code-3xx { color: #d4a54a; }
.code-4xx { color: #d08770; }
.code-5xx { color: #bf616a; }
.section {
background: #141414;
border: 1px solid #2a2520;
border-radius: 4px;
padding: 1rem;
margin-bottom: 0.8rem;
}
.section-title {
color: #d4a54a;
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.1em;
margin-bottom: 0.5rem;
}
.cause { margin-bottom: 0.3rem; }
.cause::before { content: '→ '; color: #44403a; }
.category-list { margin-top: 2rem; }
.cat-header {
font-size: 0.9rem;
margin-bottom: 0.5rem;
margin-top: 1rem;
}
.cat-item {
display: inline-block;
background: #141414;
border: 1px solid #2a2520;
border-radius: 3px;
padding: 0.2rem 0.6rem;
margin: 0.15rem;
font-size: 0.8rem;
cursor: pointer;
transition: border-color 0.15s;
}
.cat-item:hover { border-color: #d4a54a; }
.brand {
text-align: center;
color: #2a2520;
font-size: 0.75rem;
margin-top: 3rem;
}
</style>
</head>
<body>
<h1>HTTP Status Lookup</h1>
<p class="subtitle">Type a code. Get the meaning.</p>
<input type="text" id="input" placeholder="404" autofocus>
<div id="result" class="result"></div>
<div id="browse" class="category-list"></div>
<div class="brand">dev.tools by Atreus & Loki</div>
<script>
const codes = {
100: { name: 'Continue', desc: 'Server received request headers. Client should send the body.', causes: ['Large file upload with Expect: 100-continue header', 'HTTP/1.1 request pipeline'] },
101: { name: 'Switching Protocols', desc: 'Server is switching to the protocol the client requested.', causes: ['WebSocket upgrade request', 'HTTP/2 upgrade'] },
200: { name: 'OK', desc: 'Request succeeded.', causes: ['Successful GET, POST, PUT, or DELETE', 'The happy path'] },
201: { name: 'Created', desc: 'Request succeeded and a new resource was created.', causes: ['Successful POST creating a new record', 'User registration, file upload'] },
204: { name: 'No Content', desc: 'Request succeeded but there is no content to return.', causes: ['Successful DELETE request', 'PUT/PATCH that returns no body', 'Preflight CORS response'] },
301: { name: 'Moved Permanently', desc: 'Resource has been permanently moved to a new URL.', causes: ['Domain migration', 'HTTP to HTTPS redirect', 'URL structure change'] },
302: { name: 'Found', desc: 'Resource temporarily at a different URL.', causes: ['Login redirect', 'Temporary maintenance redirect', 'OAuth flow redirect'] },
304: { name: 'Not Modified', desc: 'Resource has not changed since last request. Use cached version.', causes: ['Browser cache validation with If-None-Match / If-Modified-Since', 'CDN cache hit'] },
307: { name: 'Temporary Redirect', desc: 'Same as 302 but method and body must not change.', causes: ['HTTPS upgrade preserving POST method', 'Load balancer redirect'] },
308: { name: 'Permanent Redirect', desc: 'Same as 301 but method and body must not change.', causes: ['API versioning redirect preserving method'] },
400: { name: 'Bad Request', desc: 'Server cannot process the request due to client error.', causes: ['Malformed JSON in request body', 'Missing required field', 'Invalid query parameter', 'Request too large'] },
401: { name: 'Unauthorized', desc: 'Authentication required. You are not logged in.', causes: ['Missing Authorization header', 'Expired JWT token', 'Invalid API key', 'Session expired'] },
403: { name: 'Forbidden', desc: 'You are authenticated but do not have permission.', causes: ['Insufficient role/permissions', 'IP blocked by firewall', 'CORS policy violation', 'Rate limit with auth'] },
404: { name: 'Not Found', desc: 'The requested resource does not exist.', causes: ['Typo in URL', 'Resource was deleted', 'Route not defined in server', 'Missing API version prefix'] },
405: { name: 'Method Not Allowed', desc: 'HTTP method not supported for this endpoint.', causes: ['POST to a GET-only endpoint', 'DELETE not implemented', 'Missing CORS preflight handling'] },
408: { name: 'Request Timeout', desc: 'Server timed out waiting for the request.', causes: ['Slow client connection', 'Large file upload on slow network', 'Server impatient timeout setting'] },
409: { name: 'Conflict', desc: 'Request conflicts with current state of the resource.', causes: ['Duplicate unique key (email already exists)', 'Concurrent edit conflict', 'Version mismatch in optimistic locking'] },
413: { name: 'Payload Too Large', desc: 'Request body exceeds server limit.', causes: ['File upload exceeds max size', 'JSON body too large', 'Nginx client_max_body_size exceeded'] },
415: { name: 'Unsupported Media Type', desc: 'Server does not support the Content-Type sent.', causes: ['Sending form data when API expects JSON', 'Missing Content-Type header', 'Uploading unsupported file format'] },
418: { name: "I'm a Teapot", desc: 'Server refuses to brew coffee because it is a teapot.', causes: ['RFC 2324 Hyper Text Coffee Pot Control Protocol', 'Easter egg in some APIs', 'The best status code'] },
422: { name: 'Unprocessable Entity', desc: 'Request is well-formed but contains semantic errors.', causes: ['Validation failure (email format wrong)', 'Business logic rejection', 'Invalid field value within valid JSON'] },
429: { name: 'Too Many Requests', desc: 'You have been rate limited.', causes: ['API rate limit exceeded', 'Too many login attempts', 'DDoS protection triggered', 'Check Retry-After header'] },
500: { name: 'Internal Server Error', desc: 'Server encountered an unexpected condition.', causes: ['Unhandled exception in server code', 'Database connection failure', 'Null pointer / undefined access', 'The classic "it works on my machine"'] },
502: { name: 'Bad Gateway', desc: 'Server acting as gateway received an invalid response from upstream.', causes: ['Upstream server crashed', 'Reverse proxy cannot reach backend', 'Docker container not running', 'Serverless function timeout'] },
503: { name: 'Service Unavailable', desc: 'Server is temporarily unable to handle the request.', causes: ['Server overloaded', 'Deployment in progress', 'Maintenance window', 'Database connection pool exhausted'] },
504: { name: 'Gateway Timeout', desc: 'Gateway did not receive a timely response from upstream.', causes: ['Upstream server too slow', 'Long-running query timeout', 'Network issues between proxy and backend', 'Lambda/Cloud Function cold start'] }
};
const input = document.getElementById('input');
const result = document.getElementById('result');
const browse = document.getElementById('browse');
function colorClass(code) {
if (code < 200) return 'code-1xx';
if (code < 300) return 'code-2xx';
if (code < 400) return 'code-3xx';
if (code < 500) return 'code-4xx';
return 'code-5xx';
}
function lookup(code) {
const c = codes[code];
if (!c) {
result.innerHTML = `<div class="status-line"><span class="code ${colorClass(code)}">${code}</span> — Unknown status code</div>`;
return;
}
let html = `<div class="status-line"><span class="code ${colorClass(code)}">${code}</span> ${c.name}</div>`;
html += `<div class="section"><div class="section-title">Meaning</div>${c.desc}</div>`;
html += `<div class="section"><div class="section-title">Common Causes</div>`;
c.causes.forEach(cause => { html += `<div class="cause">${cause}</div>`; });
html += `</div>`;
result.innerHTML = html;
}
input.addEventListener('input', function() {
const v = this.value.trim();
if (/^\d{3}$/.test(v)) lookup(parseInt(v));
else if (v.length > 0) {
const matches = Object.entries(codes).filter(([k,c]) =>
c.name.toLowerCase().includes(v.toLowerCase()) || c.desc.toLowerCase().includes(v.toLowerCase())
);
if (matches.length) {
result.innerHTML = matches.map(([k,c]) =>
`<div style="margin-bottom:0.5rem;cursor:pointer" onclick="document.getElementById('input').value='${k}';lookup(${k})">` +
`<span class="code ${colorClass(k)}">${k}</span> ${c.name} — <span style="color:#665e50">${c.desc}</span></div>`
).join('');
} else {
result.innerHTML = '';
}
} else {
result.innerHTML = '';
}
});
// Browse all codes
const categories = { '1xx Informational': [], '2xx Success': [], '3xx Redirection': [], '4xx Client Error': [], '5xx Server Error': [] };
Object.keys(codes).forEach(k => {
const n = parseInt(k);
if (n < 200) categories['1xx Informational'].push(k);
else if (n < 300) categories['2xx Success'].push(k);
else if (n < 400) categories['3xx Redirection'].push(k);
else if (n < 500) categories['4xx Client Error'].push(k);
else categories['5xx Server Error'].push(k);
});
let browseHtml = '';
Object.entries(categories).forEach(([cat, items]) => {
const cls = cat.startsWith('1') ? 'code-1xx' : cat.startsWith('2') ? 'code-2xx' : cat.startsWith('3') ? 'code-3xx' : cat.startsWith('4') ? 'code-4xx' : 'code-5xx';
browseHtml += `<div class="cat-header ${cls}">${cat}</div><div>`;
items.forEach(k => {
browseHtml += `<span class="cat-item" onclick="document.getElementById('input').value='${k}';lookup(${k})">${k} ${codes[k].name}</span>`;
});
browseHtml += `</div>`;
});
browse.innerHTML = browseHtml;
</script>
</body>
</html>