app1.scala
author Christian Urban <urbanc@in.tum.de>
Mon, 24 Sep 2012 20:51:17 +0100
changeset 5 1280309e6bfc
child 6 4c40d4b2d01c
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
object Application extends Controller {
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
  // presenting login form
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
  val index = Action { request =>
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
    
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
    val form = """<form method="post"> 
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
                Login: <input type="text" name="login"><br>
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
                Password: <input type="password" name="password"><br>
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
                <input type="submit"></form>"""
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
    Ok(form).as(HTML)
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  }  
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  // processing the received login data
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  val receive = Action { request =>
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
    
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
    val form_data = Form (tuple ("login" -> text, "password" -> text))
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
    val (login, password) = form_data.bindFromRequest()(request).get 
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
    
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
    Ok("Received login: " + login + " and password: " + password)
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  }
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
}
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28