-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathMain.java
More file actions
37 lines (28 loc) · 1.1 KB
/
Main.java
File metadata and controls
37 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package app;
import app.controllers.PageController;
import io.javalin.Javalin;
import io.javalin.http.staticfiles.Location;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
public class Main {
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) {
String path = "./src/main/resources/public";
File file = new File(path);
try {
LOG.info("static files served from location: {}, ready {} ", file.getCanonicalFile(), file.exists());
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
Javalin app = Javalin.create(
config -> config.staticFiles.add(path, Location.EXTERNAL)
).start(8888);
app.get("/", PageController::serveIndex);
app.get("/download.html", PageController::serveDownload);
app.get("/examples.html", PageController::serveExamples);
app.get("/news.html", PageController::serveNews);
app.get("/404.html", PageController::serve404);
}
}