app1.scala
author Christian Urban <urbanc@in.tum.de>
Tue, 23 Oct 2012 14:33:12 +0100
changeset 54 6986cd4261f2
parent 6 4c40d4b2d01c
permissions -rw-r--r--
tuned
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
6
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     3
  // GET request -> present login form
5
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
    
6
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     6
    val form = 
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     7
       """<form method="post"> 
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     8
          Login: <input type="text" name="login"><br>
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     9
          Password: <input type="password" name="password"><br>
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
    10
          <input type="submit"></form>"""
5
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
    Ok(form).as(HTML)
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  }  
1280309e6bfc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
6
4c40d4b2d01c new slides
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
    15
  // POST data: processing the login data
5
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