From 2e3606f1b6ba59975b3a0141ed3b2f6286c66ec3 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Sun, 30 Jan 2022 23:34:21 +0100
Subject: get started on submit page

---
 web/pw-server/src/routes/index.svelte | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

(limited to 'web/pw-server/src/routes/index.svelte')

diff --git a/web/pw-server/src/routes/index.svelte b/web/pw-server/src/routes/index.svelte
index 5982b0a..0e811b3 100644
--- a/web/pw-server/src/routes/index.svelte
+++ b/web/pw-server/src/routes/index.svelte
@@ -1,2 +1,27 @@
-<h1>Welcome to SvelteKit</h1>
-<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
+<script lang="ts">
+  let code = "";
+
+  async function submitCode() {
+    console.log("click");
+    let response = await fetch("/api/submit_bot", {
+      method: "POST",
+      headers: {
+        "Content-Type": "application/json",
+      },
+      body: JSON.stringify({
+        "code": code,
+      }),
+    });
+
+    if (!response.ok) {
+      throw Error(response.statusText);
+    }
+
+    let responseData = await response.json()
+    console.log(responseData);
+  }
+</script>
+
+<h1>Planetwars</h1>
+<textarea bind:value={code} />
+<button on:click={submitCode}>Submit</button>
\ No newline at end of file
-- 
cgit v1.2.3

