Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
executable file
路46 lines (40 loc) 路 2.06 KB
/
Copy pathindex.html
File metadata and controls
executable file
路46 lines (40 loc) 路 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bash Web Server Dashboard</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="container">
<header>
<h1>馃殌 Bash + Socat Web Server</h1>
<p class="subtitle">A zero-dependency (well, almost!) asynchronous HTTP server written entirely in Bash.</p>
</header>
<!-- Interactive Demo Box -->
<section class="card">
<h2>馃И Interactive Test Area</h2>
<div id="status-box">Status: Waiting for action...</div>
<button id="magic-btn">Click to Test JavaScript</button>
</section>
<!-- Project Explanation / Documentation Section -->
<section class="card docs">
<h2>馃摉 How This Project Works</h2>
<div class="doc-item">
<h3>1. The Core Engine (Socat)</h3>
<p>Instead of traditional compiled languages, this server leverages <strong>socat</strong> with the <code>,fork</code> argument. Every time a browser connects, socat instantly spawns an independent background child process to handle the request asynchronously.</p>
</div>
<div class="doc-item">
<h3>2. JSON Configuration</h3>
<p>The server reads settings directly from <code>config.json</code> using <strong>jq</strong>. It strictly enforces parameters like host, port, async mode, and served directories, failing safely if any configuration is missing.</p>
</div>
<div class="doc-item">
<h3>3. Worker Routing & Safety</h3>
<p>When a request hits the server, it passes through a worker script that sanitizes file paths to prevent directory traversal attacks (<code>../</code>), handles custom 404 responses, and maps file extensions to correct HTTP Content-Types.</p>
</div>
</section>
</div>
<script src="/scripts/main.js"></script>
</body>
</html>