serve-html
Starts a minimal HTTP server on a local port and serves a single HTML file. Every request to the server — regardless of path — returns the specified file. This is useful for previewing local HTML documents in a browser without configuring a full web server.
The server uses ASP.NET Core's built-in hosting stack. It runs until the process is terminated (Ctrl+C).
$ pbtk web serve-html
--file report.html
--port 8080
flowchart LR
CLI["pbtk web serve-html\n--file report.html\n--port 8080"] --> SRV["ASP.NET Core\nHTTP server\nbinds 0.0.0.0:8080"]
SRV --> REQ["Any HTTP request"]
REQ --> RESP["Return report.html\nContent-Type: text/html"]
The default port is 8080. If the port is already in use the server will fail to bind
and exit with an error. Pass a different
--port value to use another port.
Local use only: the server binds on all interfaces (
0.0.0.0).
Do not use this to serve sensitive files on a shared or public network.
Example workflow
Serve a documentation file while keeping the server running in a terminal:
$ pbtk web serve-html
--file docs/report.html
--port 3000
Then open http://localhost:3000 in a browser. Press Ctrl+C to stop the server.
| Option | Required | Default | Description |
|---|---|---|---|
--file | Yes | — | Path to the HTML file to serve |
--port | No | 8080 | TCP port to bind the HTTP server to |
Command Reference
| Command | Required options | Optional options | Output |
|---|---|---|---|
web serve-html |
--file |
--port (default 8080) |
HTTP server running until Ctrl+C |