Skip to content

Instantly share code, notes, and snippets.

@gaerfield
Created January 13, 2020 15:11
Show Gist options
  • Save gaerfield/199e87599f4ce1d831eb516e1c7ac5f7 to your computer and use it in GitHub Desktop.
Save gaerfield/199e87599f4ce1d831eb516e1c7ac5f7 to your computer and use it in GitHub Desktop.
using Kscript for a simple ktor-server
#!/usr/bin/env kscript
@file:MavenRepository("jcenter","https://jcenter.bintray.com" )
@file:DependsOn("io.ktor:ktor-server-netty:1.2.6")
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.*
embeddedServer(Netty, port = 8080) {
routing {
get("/") { call.respondText("Hello World!", ContentType.Text.Plain) }
get("/demo") { call.respondText("HELLO WORLD!") }
}
}.start(wait = true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment