Web服务器处理多个临时Scala脚本? [关闭]

For one of my simple appplications, all the routing is handled by nginx. I just put the php files in the directory referenced and they are serve requests: no framework is used. I am trying to migrate this scheme to Scala: I want to do it by gradually replacing each php script with one in Scala.

Is there a Scala counterpart of a php server that can automatically compile and serve all scala files under a directory? So that when I put code in /book/new.scala, /book/buy.scala, /user/login/auth.scala, etc, the server would compile and serve all of them for corresponding requests?

In the strictest technical sense, Scala can be used as a "scripting language," but it's rather limited in what can be reasonably done that way.

As others have commented, you should make a proper server for or out of you Scala application. There are many options from simple and lightweight to big and fancy. Most use the Java Servlet Container, but some implement their own HTTP server side.

You have many options to choose from, but "scripting" really is not among the viable ones.

You might look at the Lift Framework, and aim to only use the endpoint/RESTful part of the framework. In this way you can identify key requests to the webserver and pass them off to Scala-based code. Lift would manage the webserver part of everything.

That said, this is a very strange way to manage a web application, and harkens back to the 90s-era CGI-script based architectures. Ask yourself why you're attempting to model things this way before proceeding, and ask if the difficulty of running two containers (php and Scala) is really worth the trouble in order to 'ease' migration.