Advertisement
trishLEX

WebServer

Jul 3rd, 2017
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.79 KB | None | 0 0
  1. import akka.actor.ActorSystem
  2. import akka.stream.ActorMaterializer
  3. import akka.http.scaladsl.Http
  4. import akka.http.scaladsl.server.Directives._
  5.  
  6. /**
  7.   * Created by trishLEX on 03.07.2017.
  8.   */
  9. object WebServer {
  10.  
  11.   def main(args: Array[String]) {
  12.  
  13.     implicit val actorSystem = ActorSystem("system")
  14.     implicit val actorMaterializer = ActorMaterializer()
  15.  
  16.     val route =
  17.       pathSingleSlash {
  18.         complete("root")
  19.       } ~
  20.         pathPrefix("digit") {
  21.           pathEndOrSingleSlash {
  22.             complete("here a digit")
  23.           } ~
  24.             path(IntNumber) { int =>
  25.               complete(if (int % 2 == 0) "even digit" else "odd digit")
  26.             }
  27.         }
  28.  
  29.     Http().bindAndHandle(route,"localhost",8080)
  30.  
  31.     println("server started at 8080")
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement