Wizard: add basic ktor server template

This commit is contained in:
Ilya Kirillov
2019-12-13 15:42:24 +03:00
parent f927fb3471
commit 56fccce305
14 changed files with 284 additions and 97 deletions
@@ -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)
}