diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-12-28 09:09:39 +0100 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-12-28 09:09:39 +0100 |
commit | a84c09efcb2d843ee04ee3299ceb592a00a42267 (patch) | |
tree | f0fd2cf8cadd7bc4bf91ebd31bd41d34a170a7f3 /examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala | |
parent | 7d14b23dbbdaf66b222839874a29fff4a34e1762 (diff) | |
download | hands-on-scala-js-a84c09efcb2d843ee04ee3299ceb592a00a42267.tar.gz hands-on-scala-js-a84c09efcb2d843ee04ee3299ceb592a00a42267.tar.bz2 hands-on-scala-js-a84c09efcb2d843ee04ee3299ceb592a00a42267.zip |
wip
Diffstat (limited to 'examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala')
-rw-r--r-- | examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala b/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala deleted file mode 100644 index e9038b5..0000000 --- a/examples/crossBuilds/clientserver/server/src/main/scala/simple/Server.scala +++ /dev/null @@ -1,46 +0,0 @@ -package simple - -import akka.actor.ActorSystem -import spray.http.{HttpEntity, MediaTypes} -import spray.routing.SimpleRoutingApp - -import scala.util.Properties - -object Server extends SimpleRoutingApp{ - def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() - val port = Properties.envOrElse("PORT", "8080").toInt - startServer("0.0.0.0", port = port){ - get{ - pathSingleSlash{ - complete{ - HttpEntity( - MediaTypes.`text/html`, - Page.skeleton.render - ) - } - } ~ - getFromResourceDirectory("") - } ~ - post{ - path("ajax" / "list"){ - extract(_.request.entity.asString) { e => - complete { - upickle.write(list(e)) - } - } - } - } - } - } - def list(path: String) = { - val (dir, last) = path.splitAt(path.lastIndexOf("/") + 1) - val files = - Option(new java.io.File("./" + dir).listFiles()) - .toSeq.flatten - for{ - f <- files - if f.getName.startsWith(last) - } yield FileData(f.getName, f.length()) - } -}
\ No newline at end of file |