ClosedBit Server beginner course

Build a site. Host it from your device.

ClosedBit Server creates up to 20 Projects in your Documents folder. Your Windows computer serves those files directly—there is no site upload and no ClosedBit cloud hosting.

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.

Stopping the app, turning off the computer, losing its network connection, or blocking the port stops the site. ClosedBit does not copy the Project to a cloud provider.

Project file layout

The Server app creates this structure for every Project:

Documents folder
ClosedBit Server/
└── Projects/
    └── my-first-site/
        ├── project.cbs
        └── assets/
            ├── index.cb
            ├── styles.cb
            ├── app.cb
            └── images/
                └── logo.png.cb
  • .cbp is a ClosedBit program or app source file.
  • .cbs is a readable ClosedBit Server script/configuration file.
  • .cb is a validated container that can hold HTML, CSS, JavaScript, images, or app data.
  • .cbw is 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.

index.html
<!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.

styles.css
: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.

app.js
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.

pack-site.cbp
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

  1. Open ClosedBit Server and create a Project name.
  2. Place the compiled .cb assets in that Project’s assets folder.
  3. Select the Project and press Start Hosting.
  4. Open the domain shown by the app, for example cb:||my-first-site, in ClosedBit Browser.
  5. 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:

  1. Allow ClosedBit Server through Windows Firewall on Private networks.
  2. In the router, forward TCP port 8743 to the LAN IPv4 address displayed by ClosedBit Server.
  3. Use a stable DHCP reservation so the computer keeps that LAN address.
  4. Keep Windows awake and keep ClosedBit Server running.
Some Internet providers use carrier-grade NAT or block inbound traffic. In that case, ordinary router forwarding may not work; request a public IPv4 address or an inbound-capable plan from the provider. Do not expose Remote Desktop, file sharing, or unrelated ports.

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.