Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import akka.actor.ActorSystem
- import akka.http.scaladsl.Http
- import akka.http.scaladsl.model.{ContentTypes, HttpEntity}
- import akka.http.scaladsl.server.Directives._
- import akka.http.scaladsl.server.Route
- import akka.stream.ActorMaterializer
- /**
- * Created by trishLEX on 03.07.2017.
- */
- object WebServer {
- def main(args: Array[String]) {
- implicit val actorSystem = ActorSystem("system")
- implicit val actorMaterializer = ActorMaterializer()
- implicit val executionContext = actorSystem.dispatcher
- val requestHandler = actorSystem.actorOf(RequestHandler.props(), "requestHandler")
- val route: Route = {
- path("hello") {
- get {
- complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
- } ~
- post {
- entity(as[String]) {
- json => complete(json)
- }
- }
- }
- }
- Http().bindAndHandle(route,"localhost",8080)
- println("server started at 8080")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement