It's similar in spirit to Bottle or Flask
Official site : http://sparkjava.com/
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
package org.dev.artyprog; | |
import static spark.Spark.*; | |
import spark.Request; | |
import spark.servlet.SparkApplication; | |
public class HelloWorld implements SparkApplication { | |
@Override | |
public void init() { | |
get("/hello", (req, res) -> "Hello"); | |
get("/hello/:name/:age", (req, res) -> greet(req)); | |
} | |
public String greet(Request req) { | |
return "Hello " + req.params().get(":name") + | |
" you are " + req.params().get(":age"); | |
} | |
} |