Table of Contents
Kotlin can be used as script. I tried to create simple server with Kotlin script, like the server introduced in Python Light Server.
Preparation
Install Kotlin compiler.
macOS case
If you use homebrew, you can install Kotlin (kotlinc) with brew install kotlin
. In my case, it was installed as /usr/local/Cellar/kotlin/1.2.71/bin/kotlinc
.
Code
It is a socket connection code with java.net.ServerSocket
. The code is in GitHub: Kotlin-Simple-HTTP-Server, too.
Launch Server
Launch server with the following command.
When you access to localhost:8081
, you can see the page.