I am trying to learn to use ktor and I'm trying to display the text "Hello Ktor" at the root path but all I keep getting is this site can't be reached. This is my code:
import io.ktor.application.*
import io.ktor.http.ContentType
import io.ktor.response.respondText
import io.ktor.routing.get
import io.ktor.routing.routing
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
private val userData = "{\"users\": [\"Timi\", \"Tomi\", \"Temi\"]}"
@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
routing {
get("/") {
call.respondText("Hello Ktor", ContentType.Text.Plain)
}
}
}
What am I doing wrong?
http://localhost
? You should tryhttp://localhost:8080
. – ordonezalex