feat(13): starting simple web server
This commit is contained in:
parent
28f2cf281a
commit
d35bf9735c
|
@ -1,6 +1,7 @@
|
|||
package testimonialsgrid
|
||||
|
||||
import mainargs.{main, arg, ParserForMethods}
|
||||
import cask.main.Routes
|
||||
|
||||
object Main {
|
||||
@main def run(
|
||||
|
@ -9,10 +10,28 @@ object Main {
|
|||
@arg(name = "host", doc = "Host on which server will start serving.")
|
||||
hostArg: String = "localhost"
|
||||
): Unit = {
|
||||
val a = 1
|
||||
println(s"Will start server on ${hostArg}:${portArg}")
|
||||
val server = new cask.Main {
|
||||
override def allRoutes: Seq[Routes] = Seq(AppRoutes())
|
||||
override def port: Int = portArg
|
||||
override def host: String = hostArg
|
||||
}
|
||||
server.main(Array.empty)
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
||||
|
||||
case class AppRoutes()(implicit cc: castor.Context, log: cask.Logger) extends cask.Routes {
|
||||
@cask.get("/")
|
||||
def index() = {
|
||||
cask.Response("Hello")
|
||||
}
|
||||
@cask.staticFiles("/dist")
|
||||
def distFiles() = "dist"
|
||||
@cask.staticFiles("/public")
|
||||
def publicFiles() = "public"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue