Ich bin ziemlich neu zu akka. Ich habe eine html, css, jv Vorlage, die ich auf unseren Server stellen muss.Definieren zusätzlicher Pfade in 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)
}
Wie kann ich definieren die Pfade zu CSS Javascript und Bilddateien, die unter src/abc/css
sind; src/abc/jv
; src/abc/images
.
Ich habe einige Codes mit Präfix gesehen, war aber noch nicht in der Lage, es richtig zu verwenden. Auch gibt es mehrere Bilder, sollte ich sie alle erklären? Vielen Dank!
eigentlich funktioniert das nicht, stört es Sie schreiben die Importe, die Sie verwenden und das vollständige Skript? thnk Sie – uniXVanXcel
@uniXVanXcel Aktualisiert. –
Ok danke :) – uniXVanXcel