The first way to achieve this, is to use the HTML plugin. This plugin allows you to define HTML code which will be executed the moment the URL is opened. The match rule of the concept can be used to define several different personalised HTML pages in 1 DimML application
To call the DimML application (without specific headers), the following URL has to be opened:
http://dynamic.dimml.io/content/[hash]/
The hash value of the DimML application can be found by opening the O2MC studio, right clicking on Properties and clicking Publishing API. Several properties and examples are available, the second property Hash is the one that is used for content routing.
The code for a HTML page is:
@groovy concept Html { match '*.html' plugin html ` <p>What a nice line of text</p> <p>And another one!</p> ` }
Note that opening looking at the match rule in this example, the URL http://dynamic.dimml.io/content/[hash]/page.html will show the HTML code, but http://dynamic.dimml.io/content/[hash]/page.htm will not (since the match is on “.html”).
Apart from HTML code, it is also possible to route the request to specific content. For this the content plugin is used, which requires a field as argument containing the URL to route to. The following code routes the DimML URL automatically to a picture URL:
@groovy concept Img { match '*.png' flow => code[img = `"https://unsplash.it/200/300"`@groovy] => out plugin content `img` }
A more extensive example, which routes the URL to a different picture, based on the current weather can be found here.