Dev Server

Hot-reload dev server with filesystem polling and @@HOT_RELOAD dispatch.

1 min read 244 words

Milo includes a lightweight dev server that watches template files and live-reloads your app when they change. Nowatchdogdependency — just filesystem polling.

CLI usage

milo dev myapp:app
milo dev myapp:app --watch ./templates --poll 0.25

The myapp:app argument follows the module:attribute convention. Milo imports the module and looks up the Appinstance.

Programmatic usage

from milo import App, DevServer

app = App(template="dashboard.kida", reducer=reducer, initial_state=None)
server = DevServer(app, watch_dirs=("./templates",), poll_interval=0.5)
server.run()

How it works

flowchart LR FS[Filesystem] -->|poll mtime| DS[DevServer] DS -->|"@@HOT_RELOAD"| Store Store --> Reducer Reducer --> Render[Re-render]
  1. 1

    Poll

    DevServer watches directories for *.kida changes

    The server polls watched directories at a configurable interval, comparing file mtimes.

  2. 2

    Detect

    When a template file changes

    When a file's mtime changes, DevServer dispatches@@HOT_RELOADwith the changed file path.

  3. 3

    Reload

    Template environment re-reads the file

    Your reducer can handle@@HOT_RELOADto trigger re-rendering or state updates. The template environment re-reads the file on next render.

The polling approach has no native dependencies and works identically across macOS, Linux, and Windows.

Configuration

Parameter Default Description
watch_dirs () Directories to watch for template changes
poll_interval 0.5 Seconds between filesystem polls

Tip

Set--poll 0.1 for faster feedback during active template iteration. The default 0.5sis a good balance between responsiveness and CPU usage.