2
我對akka很新穎。我有一個html,css,jv模板,我需要把它放到我們的服務器上。在akka中定義額外路徑
package com.example
import akka.http.scaladsl.marshallers.xml.ScalaXmlSupport.defaultNodeSeqMarshaller
import akka.http.scaladsl.server.{ HttpApp, Route }
/**
* Server will be started calling Server_HttpApp .startServer("localhost", 8080)`
* and it will be shutdown after pressing return.
*/
object Server_HttpApp extends HttpApp with App {
def routes: Route =
pathEndOrSingleSlash { // Listens to the top `/`
complete("Helloo") // Completes with some text
} ~
path("hello") { // Listens to paths that are exactly `/hello`
get { // Listens only to GET requests
//complete(<html><body><h1>Say hello to akka-http</h1></body></html>) // Completes with some text
getFromResource("src/abc/html/index.html")
} ~
getFromResourceDirectory("src")
}
startServer("xyz" , 70)
}
我該如何定義CSS javascript和圖像文件的路徑,它們在src/abc/css
下; src/abc/jv
; src/abc/images
。
我已經看到一些代碼使用前綴,但還沒有能夠正確使用它。 此外,有多個圖像,我應該宣佈他們全部?謝謝!
實際上這不起作用,你介意寫出你使用的進口和完整的腳本嗎? thnk you – uniXVanXcel
@uniXVanXcel更新。 –
好的,謝謝:) – uniXVanXcel