'I can not get ktor, freemarker, and css to all work together
I'm trying to use Ktor to create a back end for a simple site. I can not find any documentation or examples on how to do anything that is not absolutely basic.
E.g. all I want to do at this stage is: have a template evaluated by FreeMarker (or any other method) to create a Html page that is styled using a css sheet that I have, and refer to an image that I have.
I can not get it to find/use the css or the image.
my code: index.ftl
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<header>
<div">
Hello
</div>
</header>
<body>
<div>
<h1>H1 1</h1>
<img src="/resources/imgs/Logo_cropped.jpg" alt="1">
<img src="resources/imgs/Logo_cropped.jpg" alt="2">
<img src="/imgs/Logo_cropped.jpg" alt="3">
<img src="imgs/Logo_cropped.jpg" alt="4">
<img src="/Logo_cropped.jpg" alt="5">
<img src="Logo_cropped.jpg" alt="6">
<h1>H1 2</h1>
</body>
</html>
Routing.kt
package com.example.plugins
import io.ktor.server.routing.*
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.freemarker.*
import io.ktor.server.response.*
import io.ktor.server.request.*
fun Application.configureRouting() {
routing {
get("/") {
call.respondText("Hello World!")
}
get("/h") {
call.respond(FreeMarkerContent("index.ftl", mapOf("data" to stam("John", 15)), ""))
}
}
}
data class stam(val name: String, val age: Int)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
