Hosting an HTML endpoint

Here's a more complete example for you:

definition(
        name: "Test HTML Endpoints",
        namespace: "joshualyon",
        author: "Josh Lyon",
        description: "Test HTML Endpoints",
        category: "Amazing Apps",
        iconUrl: "",
        iconX2Url: "",
        oauth: [displayName: "HTML Endpoint", displayLink: "https://sharptools.io"]){
}

preferences(){
    page(name: "setupScreen")
}

def setupScreen(){
    if(!state.accessToken){	
        //enable OAuth in the app settings or this call will fail
        createAccessToken()	
    }
    def uri = getFullLocalApiServerUrl() + "/?access_token=${state.accessToken}"
    return dynamicPage(name: "setupScreen", uninstall: true, install: true){
        section(){ 
            paragraph("Use the following URI to access the page: <a href='${uri}'>${uri}</a>")
        }
    }
}

mappings {
    //the root path - you can also map other paths or use parameters in paths and posted data
    path("/") { 			 action: [ GET: 	"renderWebsite" ] }
}

def renderWebsite(){
    log.info "Rendering page"
    html = "<html><head><title>Awesome Page</title></head><body><h1>hello world</h1></body></html>"
    render contentType: "text/html", data: html, status: 200
}
5 Likes