Cookbook/CustomWeb

From Kx Wiki
Jump to: navigation, search

The wiki is moving to a new format and this page is no longer maintained. You can find the new page at code.kx.com/q/cookbook/custom-web.

The wiki will remain in place until the migration is complete. If you prefer the wiki to the new format, please tell the Librarian why.

Customising the default kdb+ webserver

Without changing anything in kdb+ you can make a kdb+ session serve up static content by creating a directory called "html" underneath your QHOME directory. This is the root server for the webserver (like the apache /var/www/html) and is the place to save static content to be served up from kdb+. Try for example saving a favicon.ico file there and calling up a page.

The default location can be changed by setting the variable .h.HOME.

Every http request that comes into a kdb+ session is handled by .z.ph. By default it simply wraps the output from showing the data requested inside a fixed width tag (xmp) and sends it back. This is fast and simple, and will work in all browsers - even internet explorer - but makes it very difficult to apply any CSS styling to the data.

If you're prepared to make changes the sample code in the doth directory shows how to modify the .z.ph code to output table data as a simple HTML table, and then to add Javascript and CSS files to decorate the output. To use it put the doth.k file in your QHOME, and the two plaid.* files in your QHOME/html directory (create it if necessary) - then \l doth.k.

The javascript used to do the formatting of the rows and columns came from an article Plaid-Striped HTML Tables that is no longer available, but the same thing could be done with any of the many other solutions you'll find with a quick google.

Plaid.png

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox