jdkx32 / cchub-web public advancedcomputerpocketturtle
0
0
Web IDE
main
3 commits
jdkx32 Update cchub-web client files
ae4daa90 2026-09-28
Update cchub-web client files2026-09-28
Update cchub-web client files2026-09-28
Update cchub-web client files2026-09-28
main
Update cchub-web client files2026-09-28
README.md
MIT

cchub-web

Official Web Server & HTTP Tunnel Gateway client for ComputerCraft in JavaScript (hJS) and Lua.

Quick Install on your ComputerCraft device

Type this command in the terminal:

hpm install cchub-web
hub get cchub-web

cchub-web

Official Web Server & HTTP Tunnel Gateway client for ComputerCraft in JavaScript (hJS) and Lua.

Host live public websites, dashboards, and REST APIs straight from your in-game ComputerCraft computers and turtles! Anyone on the real internet can access your computer at: https://cc.jeremyleonklink.de/web/<your-site-name>


🚀 Quickstart in JavaScript (hJS)

1. Install via hpm

bash
hpm install cchub-web

2. Create main.hjs

javascript
const { createServer } = require("cchub-web");

const app = createServer({
  site: "my-base",
  token: "YOUR_SECRET_TOKEN" // from https://cc.jeremyleonklink.de/web
});

// HTML Webpage
app.get("/", (req, res) => {
  res.html(`
    <!DOCTYPE html>
    <html>
      <head><title>My Base</title></head>
      <body style="font-family: sans-serif; background: #111; color: #eee; padding: 2rem;">
        <h1>⚡ Live Minecraft Base Server</h1>
        <p>Served directly by ComputerCraft & hJS!</p>
        <p>In-game time: ${os.time()}</p>
      </body>
    </html>
  `);
});

// JSON API
app.get("/api/status", (req, res) => {
  res.json({
    status: "online",
    time: os.time(),
    day: os.day(),
    fuel: typeof turtle !== "undefined" ? turtle.getFuelLevel() : null
  });
});

// Serve static files from /www folder
app.static("/www");

app.listen((url) => {
  console.log("Server live at: " + url);
});

3. Run It!

bash
hjs run main.hjs

📜 Quickstart in Lua

If you prefer standard Lua:

lua
local web = require("cchub-web")

local app = web.createServer({
  site = "my-base",
  token = "YOUR_SECRET_TOKEN"
})

app.get("/", function(req, res)
  res.html("<h1>Hello from Minecraft ComputerCraft!</h1>")
end)

app.get("/api/status", function(req, res)
  res.json({ status = "online", time = os.time() })
end)

app.listen()

📚 API Reference

createServer(options)

  • site (string, required): The slug registered under /web.
  • token (string, required): Secret access token generated for this tunnel.
  • endpoint (string, optional): Default is https://cc.jeremyleonklink.de.

Routing Methods

  • app.get(path, handler)
  • app.post(path, handler)
  • app.put(path, handler)
  • app.delete(path, handler)
  • app.all(path, handler)
  • app.static(folderPath, mountPoint = "/")
  • app.listen([callback])
  • app.close()

Request Object (req)

  • req.method: HTTP method ("GET", "POST", etc.)
  • req.path: Requested path (e.g. "/api/status")
  • req.query: Object of query string parameters
  • req.headers: Object containing HTTP headers
  • req.body: Raw request body string

Response Object (res)

  • res.status(statusCode): Sets HTTP status code (200, 404, 500, etc.)
  • res.header(name, value): Sets a response header
  • res.html(htmlString): Sends HTML with Content-Type: text/html
  • res.json(data): Sends JSON with Content-Type: application/json
  • res.text(textString): Sends plain text
  • res.send(data): Sends raw response body
Careful what you run: This script was written by jdkx32, not by us. It runs with full access to the computer you install it on — it can read and delete files there. Read it before you run it.

About

Official Web Server & HTTP Tunnel Gateway client for ComputerCraft in JavaScript (hJS) and Lua.

MIT License
★ 0 stars
11 in-game downloads
hpm Package Manifest
Version v1.0.0
Entrypoint index.hjs

Hardware Targets

advancedcomputerpocketturtle

Owner