Docserver

Launch an HTTP server that serves documentation files as HTML with markdown rendering.

Usage

duso -docserver

This starts an HTTP server on http://localhost:5150 that:

The server URL is copied to your clipboard automatically.

Features

Accessing Files

Files are loaded from the local filesystem first, then from embedded files if not found locally.

Caching

The docserver automatically caches rendered HTML in-memory for performance:

Normal mode (caching enabled):

duso -docserver

Development mode (caching disabled):

duso -config "docserver_dev=true" -docserver

How It Works

The caching uses Duso's thread-safe datastore() with a "docserver" namespace:

This demonstrates a practical pattern for semi-production web servers: use datastore for coordinating state across concurrent request handlers.

Customization

Edit stdlib/docserver/docserver.du to:

Implementation

The docserver is implemented as a self-referential HTTP handler script that:

  1. Sets up routes on startup
  2. Handles both static files and markdown rendering
  3. Uses the markdown module for markdown parsing