mirror of
https://github.com/SinTan1729/chhoto-url
synced 2024-12-26 23:58:35 -06:00
Added static file configuration to main
This commit is contained in:
parent
d80024c494
commit
cf4d7a8496
1 changed files with 17 additions and 2 deletions
|
@ -4,9 +4,24 @@ import static spark.Spark.*;
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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";
|
||||||
|
});
|
||||||
|
|
||||||
get("/all", Routes::getAll);
|
get("/all", Routes::getAll);
|
||||||
post("/new", Routes::addUrl);
|
post("/new", Routes::addUrl);
|
||||||
get("/:shortUrl", Routes::goToLongUrl);
|
get("/:shortUrl", Routes::goToLongUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue