import io.ktor.server.application.* import io.ktor.server.cio.* import io.ktor.server.engine.* import io.ktor.server.response.* import io.ktor.server.routing.* import java.io.File import java.util.* fun main(args: Array) { val propertiesPath = args.firstOrNull() ?: error("missing properties file arg") val propertiesFile = File(propertiesPath).takeIf(File::exists) ?: error("could not find properties file $propertiesPath") val properties = propertiesFile.reader().use { reader -> Properties().apply { load(reader) }.map { (k, v) -> k.toString() to v.toString() } } embeddedServer( CIO, port = 8080, module = Application::myApplicationModule ).start(wait = true) } fun Application.myApplicationModule( properties: Map ) { routing { get("/") { call.respondText(properties["helloWorldResponse"]!!) } } }