Wizard: add basic ktor server template
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
import io.ktor.application.call
|
||||
import io.ktor.html.respondHtml
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.routing.get
|
||||
import io.ktor.routing.routing
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import ${serverEngine.getImport()}
|
||||
import kotlinx.html.*
|
||||
|
||||
fun HTML.index() {
|
||||
head {
|
||||
title("Hello from Ktor!")
|
||||
}
|
||||
body {
|
||||
div {
|
||||
+"Hello from Ktor"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
embeddedServer(${serverEngine.getEngineName()}, port = 8080, host = "127.0.0.1") {
|
||||
routing {
|
||||
get("/") {
|
||||
call.respondHtml(HttpStatusCode.OK, HTML::index)
|
||||
}
|
||||
}
|
||||
}.start(wait = true)
|
||||
}
|
||||
Reference in New Issue
Block a user