initial commit , first one was bullshit
This commit is contained in:
29
src/main/java/com/filejet/API/Server.java
Normal file
29
src/main/java/com/filejet/API/Server.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.filejet.API;
|
||||
// server logic
|
||||
|
||||
import com.filejet.API.routes.DownloadRoute;
|
||||
import com.filejet.API.util.EnvLoader;
|
||||
import io.javalin.Javalin;
|
||||
|
||||
|
||||
public class Server {
|
||||
public static void main(String[] args) {
|
||||
Javalin app = Javalin.create(config -> {
|
||||
config.staticFiles.add("/HTML/");
|
||||
}).start(EnvLoader.getPort());
|
||||
|
||||
app.get("/api/download", DownloadRoute::handle); // for ?path=... downloads
|
||||
app.get("/api/download/{file}", DownloadRoute::handle); // legacy/compat
|
||||
app.get("/api/list-isos", DownloadRoute::list);
|
||||
|
||||
app.before("/api/*", ctx -> {
|
||||
String ua = ctx.header("User-Agent");
|
||||
if (ua == null || ua.toLowerCase().contains("bot")
|
||||
|| ua.toLowerCase().contains("curl")
|
||||
) {
|
||||
ctx.status(403).result("Forbidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user