Your device is the server
When you press Start Hosting, ClosedBit Server listens for the ClosedBit protocol on your selected TCP port and reads each Project from Documents\ClosedBit Server\Projects. A Project named default owns cb:||default; its device address is resolver data and is not shown as the site URL.
Project file layout
The Server app creates this structure for every Project:
ClosedBit Server/
└── Projects/
└── my-first-site/
├── project.cbs
└── assets/
├── index.cb
├── styles.cb
├── app.cb
└── images/
└── logo.png.cb.cbpis a ClosedBit program or app source file..cbsis a readable ClosedBit Server script/configuration file..cbis a validated container that can hold HTML, CSS, JavaScript, images, or app data..cbwis a portable ClosedBit Web bundle that can hold a whole site.
Lesson 1: HTML gives the page structure
HTML describes what exists: headings, text, buttons, images, navigation, forms, and sections. Create a working index.html before compiling it into index.cb.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first ClosedBit site</title>
<link rel="stylesheet" href="styles.css">
<script defer src="app.js"></script>
</head>
<body>
<main class="card">
<p class="eyebrow">Hosted from my device</p>
<h1>Hello, ClosedBit.</h1>
<p id="message">This page has HTML, CSS, and JavaScript.</p>
<button id="hello" type="button">Test JavaScript</button>
</main>
</body>
</html>
Lesson 2: CSS controls the appearance
CSS selects HTML elements and changes their layout, color, spacing, and type. The dot in .card selects an element whose class is card.
:root { color-scheme: dark; font-family: "Segoe UI", sans-serif; }
body {
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #081016;
color: #eaf7f4;
}
.card {
width: min(620px, calc(100% - 48px));
padding: 48px;
border: 1px solid #25473f;
border-radius: 24px;
background: #101c22;
}
.eyebrow { color: #77e6c4; text-transform: uppercase; }
button { padding: 12px 18px; border: 0; border-radius: 10px; background: #77e6c4; }
Lesson 3: JavaScript adds behavior
JavaScript can listen for user actions and update the document. Keep scripts small, load them with defer, and avoid third-party trackers.
const button = document.querySelector("#hello");
const message = document.querySelector("#message");
button.addEventListener("click", () => {
message.textContent = "JavaScript is working.";
});
Put web files into validated .cb containers
The readable source files are convenient while coding. The Server serves validated .cb containers. Store each source file with the matching web name: index.html → index.cb, styles.css → styles.cb, and app.js → app.cb.
library CB-Storage
fn main() {
CB-Storage.write_text("assets/index.cb", CB-Storage.read_text("source/index.html"))
CB-Storage.write_text("assets/styles.cb", CB-Storage.read_text("source/styles.css"))
CB-Storage.write_text("assets/app.cb", CB-Storage.read_text("source/app.js"))
println("Site assets packed")
}
Binary images use the binary storage helper supplied by the current ClosedBit libraries; preserve the original extension before .cb, such as logo.png.cb, so the Server sends the correct media type.
Start and test the Server
- Open ClosedBit Server and create a Project name.
- Place the compiled
.cbassets in that Project’sassetsfolder. - Select the Project and press Start Hosting.
- Open the domain shown by the app, for example
cb:||my-first-site, in ClosedBit Browser. - Test the same domain from a second device on the same Wi-Fi or Ethernet network.
Make the device reachable from the public Internet
Local ClosedBit hosting works on the LAN first. Public access normally requires two owner-controlled network changes. These expose the ClosedBit protocol—not an HTTP or HTTPS website:
- Allow ClosedBit Server through Windows Firewall on Private networks.
- In the router, forward TCP port
8743to the LAN IPv4 address displayed by ClosedBit Server. - Use a stable DHCP reservation so the computer keeps that LAN address.
- Keep Windows awake and keep ClosedBit Server running.
Registered and approved identities
Hosting a Project and owning a protocol identity are different operations. A cb:|| name is registered but warning-marked. A ClosedBit:|| identity is approved only after valid business documentation, profit evidence, and a code audit. Capitalization does not change either protocol.
