app1.scala
author Christian Urban <urbanc@in.tum.de>
Tue, 25 Sep 2012 01:32:01 +0100
changeset 6 4c40d4b2d01c
parent 5 1280309e6bfc
permissions -rw-r--r--
new slides

object Application extends Controller {

  // GET request -> present login form
  val index = Action { request =>
    
    val form = 
       """<form method="post"> 
          Login: <input type="text" name="login"><br>
          Password: <input type="password" name="password"><br>
          <input type="submit"></form>"""

    Ok(form).as(HTML)
  }  

  // POST data: processing the login data
  val receive = Action { request =>
    
    val form_data = Form (tuple ("login" -> text, "password" -> text))

    val (login, password) = form_data.bindFromRequest()(request).get 
    
    Ok("Received login: " + login + " and password: " + password)
  }
}