SNRK-90: return html as string

This commit is contained in:
Anton Belyi 2023-05-12 18:06:57 +03:00
parent f477af64e6
commit 8ffda3f42a

View File

@ -8,17 +8,14 @@ import io.ktor.server.application.*
import io.ktor.server.html.* import io.ktor.server.html.*
import io.ktor.server.request.* import io.ktor.server.request.*
import io.ktor.server.response.* import io.ktor.server.response.*
import io.ktor.server.http.content.*
import kotlinx.html.* import kotlinx.html.*
import io.ktor.server.routing.* import io.ktor.server.routing.*
import kotlinx.css.html
import java.nio.file.Path import java.nio.file.Path
import space.kscience.snark.storage.Directory import space.kscience.snark.storage.Directory
import space.kscience.snark.storage.local.localStorage import space.kscience.snark.storage.local.localStorage
import kotlin.io.path.createTempDirectory import kotlin.io.path.createTempDirectory
import kotlin.io.path.isDirectory import kotlin.io.path.isDirectory
import kotlin.io.path.listDirectoryEntries import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.name
import space.kscience.snark.storage.unzip.unzip import space.kscience.snark.storage.unzip.unzip
public interface DataHolder { public interface DataHolder {
@ -56,7 +53,7 @@ class LocalDataHolder: DataHolder {
public class SNARKServer(val dataHolder: DataHolder, val port: Int): Runnable { public class SNARKServer(val dataHolder: DataHolder, val port: Int): Runnable {
private suspend fun renderGet(call: ApplicationCall) { private suspend fun renderGet(call: ApplicationCall) {
call.respondText(dataHolder.represent()) call.respondText(dataHolder.represent(), ContentType.Text.Html)
} }
private suspend fun renderUpload(call: ApplicationCall) { private suspend fun renderUpload(call: ApplicationCall) {
val multipartData = call.receiveMultipart() val multipartData = call.receiveMultipart()