28 lines
730 B
Java
Raw Normal View History

2020-02-13 23:52:33 +01:00
package tk.draganczuk.url;
import static spark.Spark.*;
public class App {
public static void main(String[] args) {
// Useful for developing the frontend
// http://sparkjava.com/documentation#examples-and-faq -> How do I enable automatic refresh of static files?
if (System.getenv("dev").equals("true")) {
String projectDir = System.getProperty("user.dir");
String staticDir = "/src/main/resources/public";
staticFiles.externalLocation(projectDir + staticDir);
} else {
staticFiles.location("/public");
}
get("/", (req, res) -> {
res.redirect("/index.html");
return "Redirect";
});
2020-02-13 23:52:33 +01:00
get("/all", Routes::getAll);
post("/new", Routes::addUrl);
get("/:shortUrl", Routes::goToLongUrl);
}
2020-02-13 23:52:33 +01:00
}