Skip to content

Instantly share code, notes, and snippets.

@rch850
Created July 28, 2021 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rch850/d4e527d4820dfff98f90ca82ad332890 to your computer and use it in GitHub Desktop.
Save rch850/d4e527d4820dfff98f90ca82ad332890 to your computer and use it in GitHub Desktop.
hello-ktor.main.kts
// 参考:
// * https://blog1.mammb.com/entry/2020/12/08/224315
@file:DependsOn("io.ktor:ktor-server-netty:1.4.3")
@file:DependsOn("ch.qos.logback:logback-classic:1.2.3")
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
fun main() {
val server = embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello World!", ContentType.Text.Plain)
}
get("/demo") {
call.respondText("HELLO WORLD!")
}
}
}
server.start(wait = true)
}
print("Start...")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment