【文件属性】:
文件名称:ktor:用于在Kotlin中快速创建已连接应用程序的框架
文件大小:2.56MB
文件格式:ZIP
更新时间:2021-02-03 08:54:49
kotlin web async asynchronous web-framework
Ktor是用于创建微服务,Web应用程序等的异步框架。 从头开始写在Kotlin。
import io.ktor.server.netty.*
import io.ktor.routing.*
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.server.engine.*
fun main ( args : Array < String>) {
embeddedServer( Netty , 8080 ) {
routing {
get( " / " ) {
call.respondText( " Hello, world! " , ContentType . Text . Html )
}
}
}.start(wait = true )
}
在localhost:8080上运行嵌入式Web服务器
安装路由并用Hello