Last active
May 7, 2016 22:55
-
-
Save przemek-pokrywka/39e7459e0b7ae3f7fb35b9320a57c6dc to your computer and use it in GitHub Desktop.
Serve a webpage using Play framework with a simple script. Nothing more, than Linux and Java required. Thanks to brilliant work of Alexandre Archambault, @li_haoyi and Play developers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
test -e ~/.coursier/cr || (mkdir -p ~/.coursier && wget -q -O ~/.coursier/cr https://git.io/vgvpD && chmod +x ~/.coursier/cr) | |
CLASSPATH="$(~/.coursier/cr fetch -q -p \ | |
\ | |
com.typesafe.play:play-netty-server_2.11:2.5.0 \ | |
com.typesafe.play:play_2.11:2.5.0 \ | |
com.lihaoyi:ammonite-repl_2.11.7:0.5.2 \ | |
\ | |
)" java \ | |
-Dplay.crypto.secret=foo.bar.baz \ | |
-Dconfig.resource=reference.conf \ | |
ammonite.repl.Main <(cat << "EOF" | |
import play.core.server._ | |
import play.api.routing.sird._ | |
import play.api.mvc._ | |
val server = NettyServer.fromRouter(ServerConfig( | |
port = Some(19000), | |
address = "127.0.0.1" | |
)) { | |
case GET(p"/hello/$to") => Action { | |
Results.Ok(s"Hello $to") | |
} | |
} | |
readLine | |
server.stop() | |
EOF | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment