Webview:hostfromfolder(hostname, folder) method


Maps a virtual host name to a folder path. Any resource using this host name will be loaded from that local folder.

Parameters

hostname

A string representing the virtual host name.

folder

A string representing the path to the local folder to be mapped to.

Return value

This function returns true if the operation was successful or false otherwise.

Example

local html = [[ <!DOCTYPE html> <html> <body> <center style="margin-top:35%"><a href="https://www.myfolder.com/]]..sys.File(arg[0]).name..[[">Local source code</a></center> </body> </html>]] local ui = require "ui" require "webview" -- create a simple Webview local win = ui.Window("Webview:hostfromfolder() sample", 640, 480) local Webview = ui.Webview(win, "") Webview.align = "all" -- once ready, map a virtual hostname with the current local folder -- and load the html content from string function Webview:onReady() Webview:hostfromfolder("www.myfolder.com", sys.currentdir) Webview:loadstring(html) end -- update the user interface until the user closes the Window ui.run(win):wait()