init(15): server returns dummy index from template
This commit is contained in:
parent
c27cb67c2a
commit
a2418a810c
|
@ -0,0 +1,2 @@
|
||||||
|
version = "3.7.3"
|
||||||
|
runner.dialect = scala3
|
|
@ -0,0 +1 @@
|
||||||
|
hello from the resource file!
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html class="no-js" lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
<title>TEst</title>
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||||
|
<!-- Place favicon.ico in the root directory -->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--[if lt IE 8]>
|
||||||
|
<p class="browserupgrade">
|
||||||
|
You are using an <strong>outdated</strong> browser. Please
|
||||||
|
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||||
|
your experience.
|
||||||
|
</p>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>Hello!</h1>
|
||||||
|
<secion>
|
||||||
|
<p>
|
||||||
|
into the template
|
||||||
|
</p>
|
||||||
|
</secion>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -10,6 +10,12 @@ object Main {
|
||||||
hostArg: String = "localhost"
|
hostArg: String = "localhost"
|
||||||
): Unit = {
|
): Unit = {
|
||||||
println(s"Will start server on ${hostArg}:${portArg}")
|
println(s"Will start server on ${hostArg}:${portArg}")
|
||||||
|
val server = new cask.Main {
|
||||||
|
override def allRoutes: Seq[cask.main.Routes] = Seq(Routes())
|
||||||
|
override def port: Int = portArg
|
||||||
|
override def host: String = hostArg
|
||||||
|
}
|
||||||
|
server.main(Array.empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package multistepform
|
||||||
|
|
||||||
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||||
|
import org.thymeleaf.TemplateEngine
|
||||||
|
import org.thymeleaf.context.Context
|
||||||
|
|
||||||
|
case class Routes()(implicit cc: castor.Context, log: cask.Logger)
|
||||||
|
extends cask.Routes {
|
||||||
|
val templateResolver = new ClassLoaderTemplateResolver()
|
||||||
|
templateResolver.setPrefix("templates/");
|
||||||
|
templateResolver.setSuffix(".html")
|
||||||
|
templateResolver.setTemplateMode("HTML5")
|
||||||
|
|
||||||
|
val templateEngine = new TemplateEngine()
|
||||||
|
templateEngine.setTemplateResolver(templateResolver)
|
||||||
|
|
||||||
|
@cask.get("/")
|
||||||
|
def getIndex() = {
|
||||||
|
val context = new Context()
|
||||||
|
val indexPage = templateEngine.process("index", context)
|
||||||
|
cask.Response(
|
||||||
|
indexPage,
|
||||||
|
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.staticResources("/public")
|
||||||
|
def publicFiles() = "public"
|
||||||
|
|
||||||
|
initialize()
|
||||||
|
}
|
Loading…
Reference in New Issue