diff --git a/src/main/java/me/youhavetrouble/inviter/http/endpoints/HandlerKernel.java b/src/main/java/me/youhavetrouble/inviter/http/endpoints/HandlerKernel.java
index d563694..f0b94f1 100644
--- a/src/main/java/me/youhavetrouble/inviter/http/endpoints/HandlerKernel.java
+++ b/src/main/java/me/youhavetrouble/inviter/http/endpoints/HandlerKernel.java
@@ -14,6 +14,9 @@ public class HandlerKernel implements HttpHandler {
public HandlerKernel() {
handlers.add(new GetDiscordInviteByGuildId());
+
+ // Static endpoints
+ handlers.add(new MainEndpoint());
}
@Override
diff --git a/src/main/java/me/youhavetrouble/inviter/http/endpoints/MainEndpoint.java b/src/main/java/me/youhavetrouble/inviter/http/endpoints/MainEndpoint.java
new file mode 100644
index 0000000..88cc1a1
--- /dev/null
+++ b/src/main/java/me/youhavetrouble/inviter/http/endpoints/MainEndpoint.java
@@ -0,0 +1,54 @@
+package me.youhavetrouble.inviter.http.endpoints;
+
+import com.sun.net.httpserver.HttpExchange;
+import me.youhavetrouble.inviter.Main;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.regex.Pattern;
+
+public class MainEndpoint implements EndpointHandler {
+
+ private final Pattern pathPattern = Pattern.compile("^/$");
+
+ private final String template;
+
+ public MainEndpoint() {
+ String rawTemplate = null;
+ try (InputStream resource = this.getClass().getResourceAsStream("/template/index.html")) {
+ rawTemplate = new String(resource.readAllBytes());
+ rawTemplate = rawTemplate.replaceAll("\\{\\{discord_app_id}}", Main.getJda().getSelfUser().getApplicationId());
+ } catch (IOException | NullPointerException e) {
+ Main.LOGGER.warn("Failed to load template for main endpoint", e);
+ }
+ this.template = rawTemplate;
+ }
+
+ @NotNull
+ @Override
+ public Pattern pathPattern() {
+ return pathPattern;
+ }
+
+ @Override
+ public void handle(@NotNull HttpExchange exchange) throws IOException {
+ if (template == null) {
+ exchange.sendResponseHeaders(404, -1);
+ return;
+ }
+
+ if (!exchange.getRequestMethod().equals("GET")) {
+ exchange.sendResponseHeaders(405, -1);
+ return;
+ }
+
+ exchange.getResponseHeaders().set("Content-Type", "text/html; charset=UTF-8");
+ exchange.sendResponseHeaders(200, template.getBytes(StandardCharsets.UTF_8).length);
+ exchange.getResponseBody().write(template.getBytes(StandardCharsets.UTF_8));
+ exchange.getResponseBody().close();
+
+ }
+
+}
diff --git a/src/main/resources/template/index.html b/src/main/resources/template/index.html
new file mode 100644
index 0000000..ceefbf1
--- /dev/null
+++ b/src/main/resources/template/index.html
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Discord Inviter
+
+
+
+
+
+
Inviter
+
Creates permanent invite links that make and recreate invite links if they expire or get removed.
+
Install the bot
+
+
+
Usage
+
+ - Install the bot using the button above.
+ -
+
+ Enable developer mode
+ in your discord client and copy your guilds ID.
+
+ - Now you can use https://inviter.yht.one/invite/<your_guild_id>
+
+
+
+
+