From 1c2966b14040d318aec12b38b76b9818d137dc76 Mon Sep 17 00:00:00 2001 From: Valentijn van der Jagt <1119935@hr.nl> Date: Mon, 29 Dec 2025 22:53:42 +0100 Subject: [PATCH] added web template --- .../nl/herpiederpiee/appie_scraper/Main.java | 28 +++++++++++-------- .../appie_scraper/WebServer.java | 12 ++++++++ src/main/resources/application.properties | 2 ++ src/main/resources/templates/index.html | 10 +++++++ 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 src/main/java/nl/herpiederpiee/appie_scraper/WebServer.java create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/templates/index.html diff --git a/src/main/java/nl/herpiederpiee/appie_scraper/Main.java b/src/main/java/nl/herpiederpiee/appie_scraper/Main.java index 16d1f8a..e6e3fd0 100644 --- a/src/main/java/nl/herpiederpiee/appie_scraper/Main.java +++ b/src/main/java/nl/herpiederpiee/appie_scraper/Main.java @@ -2,27 +2,33 @@ package nl.herpiederpiee.appie_scraper; import com.microsoft.playwright.*; import org.json.*; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + import java.util.ArrayList; import java.util.Scanner; + +@SpringBootApplication public class Main { public static void main(String[] args) { BonusManager.updateBonusItems(); - Scanner input = new Scanner(System.in); + // start the webserver + SpringApplication.run(Main.class, args); - while (true) { - System.out.println("\n\nWhat item would you like to look for?"); - String userInput = input.nextLine(); - if (userInput.equals("qqq")) break; - ArrayList userResults = BonusManager.getBonusItems(userInput); - - for (BonusItem bonusItem : userResults) { - System.out.println(bonusItem.title + " => " + bonusItem.bonusText); - } - } +// while (true) { +// System.out.println("\n\nWhat item would you like to look for?"); +// String userInput = input.nextLine(); +// if (userInput.equals("qqq")) break; +// ArrayList userResults = BonusManager.getBonusItems(userInput); +// +// for (BonusItem bonusItem : userResults) { +// System.out.println(bonusItem.title + " => " + bonusItem.bonusText); +// } +// } } } diff --git a/src/main/java/nl/herpiederpiee/appie_scraper/WebServer.java b/src/main/java/nl/herpiederpiee/appie_scraper/WebServer.java new file mode 100644 index 0000000..820a987 --- /dev/null +++ b/src/main/java/nl/herpiederpiee/appie_scraper/WebServer.java @@ -0,0 +1,12 @@ +package nl.herpiederpiee.appie_scraper; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class WebServer { + @GetMapping("/") + public String index() { + return "index"; // resolves to index.html in templates/ + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..16552b1 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port=9823 +spring.application.name=AppieBonusScraper \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..a78c5b2 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,10 @@ + + + + + Appie Scraper + + +

Hello World

+ +