A Javascript micro web framework for the JVM. Download/Installation instructions here.
// app.js
app.get('/hello', function(req, res) {
res.render({ text: 'hello' });
});
Run using Pachyderm:
./bin/pachyderm ~/app.js
View response at http://localhost:8080/hello
Pachyderm uses underscore.js templating for rendering views. By default, views go in the /views folder relative to the Javascript app code.
app.get('/example/{number}', function(req, res) {
var value = req.getParams().get("number");
res.render({ view: "example.html", model: { someValue: value }});
});
View code (in views directory):
<!-- views/example.html -->
<li><%= someValue %></li>
View response at http://localhost:8080/example/12
app.get('/example', function(req, res) {
res.render({json: { value: "something", other: 12.0 }});
}
View response at http://localhost:8080/example
Pachyderm can resolve Java dependencies at runtime:
with(maven) {
addDependency("commons-email:commons-email:1.1");
}
app.get('/email', function(req, res) {
var email = new org.apache.commons.mail.SimpleEmail();
email.setHostName("mail.myserver.com");
email.addTo("[email protected]", "John Doe");
email.setFrom("[email protected]", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();
});
// set the port to 8181
config.setPort(8181);
app.get('/', function(req, res) {
res.render({ text: 'port changed to 8181' });
}