Stonks/app/src/main/kotlin/xyz/etztech/stonks/App.kt

33 lines
747 B
Kotlin

/*
* This Kotlin source file was generated by the Gradle 'init' task.
*/
package xyz.etztech.stonks
import io.javalin.Javalin
import kotlinx.coroutines.*
fun main() {
println("Starting Stonks...")
var apiServerPort = 7000
initApiServer(apiServerPort)
var periodicFetchingInterval = 1000L
initPeriodicFetching(periodicFetchingInterval)
}
fun initApiServer(apiServerPort: Int) {
val app = Javalin.create().start(apiServerPort)
app.get("/") { ctx -> ctx.result("Hello World") }
}
fun initPeriodicFetching(interval: Long) =
runBlocking {
launch {
while (true) {
println("Stonks!")
delay(interval)
}
}
}