Created
July 28, 2021 01:38
-
-
Save rch850/d4e527d4820dfff98f90ca82ad332890 to your computer and use it in GitHub Desktop.
hello-ktor.main.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 参考: | |
// * 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