app1.scala
changeset 93 82ac034dcc9d
parent 92 af1aeec504cb
child 94 caf08b02fa32
equal deleted inserted replaced
92:af1aeec504cb 93:82ac034dcc9d
     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 
       
    20     val (login, password) = form_data.bindFromRequest()(request).get 
       
    21     
       
    22     Ok("Received login: " + login + " and password: " + password)
       
    23   }
       
    24 }
       
    25 
       
    26 
       
    27