Embedded Webserver Commands

Brainhat includes a webserver. It supports embedded Brainhat functionality.

Brainhat serves web content from the html subdirectory. Some commands can be embedded in html content. This is how an embedded command is structured:

<?brainhat ...some command... ?>

Any debug command can be embedded. Here is a sample web page demonstrating with the debug command "version":

<html>
<head>
  <title>Brainhat Web Page</title>
</head>
<body>

  This page tests debug through the web interface.

<p>
  The output appears below:
<div class="command-output">
&nbsp;
<p>
  <pre>
    <?brainhat debug version?>
  </pre>
  <p>
&nbsp;
</div>
<p>
  End of test.
<p>
</body>
</html>

Here is the output:

This page tests debug through the web interface.

<?brainhat debug version?>

The output appears below:

 Server version 4.260324  

End of test.

To run Brainhat with its internal webserver, use the "-W" flag on the command line. You will usually include the "+repeat" flag, too.  The webserver runs on port 4145. If you wish to use a different port, specify with the "-p" flag.

$ ./brainhat -W +repeat

>> 

Other embedded commands are "version" (which accomplishes the same thing as our example above) and "include", which copies a file into the output.  

Some debug commands that can be useful for embedding Brainhat in a web page are: "input" and "spkrinput".  You may also set and clear state flags, ala "set verbatim". The command will tell Brainhat something that will become part of the running context.

<?brainhat debug input the dog wants a bone.?>

Output, if any, will replace the embedded command in the served page.

 
Copyright © 2026, Kevin Dowd. Contact: dowd@atlantic.com.