progs/app1.scala
changeset 197 9c968d0de9a0
parent 196 22f027da67ec
child 198 2ce98ee39990
equal deleted inserted replaced
196:22f027da67ec 197:9c968d0de9a0
     1 object Application extends Controller {
       
     2 
       
     3   // GET request -> present login form
       
     4   val index = Action { request =>
       
     5     
       
     6     val form = 
       
     7        """<form method="post"> 
       
     8           Login: <input type="text" name="login"><br>
       
     9           Password: <input type="password" name="password"><br>
       
    10           <input type="submit"></form>"""
       
    11 
       
    12     Ok(form).as(HTML)
       
    13   }  
       
    14 
       
    15   // POST data: processing the login data
       
    16   val receive = Action { request =>
       
    17     
       
    18     val form_data = Form(tuple ("login" -> text, "password" -> text))
       
    19     def (login, passwd) = form_data.bindFromRequest()(request).get
       
    20     
       
    21     Ok(s"Received login: $login and password: $passwd")
       
    22   }
       
    23 }
       
    24 
       
    25 
       
    26