aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-30 23:41:47 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-30 23:41:47 +0100
commit0f27ca80fbdb3366e047def628123d3cc8ca051c (patch)
tree8363206692757f92e4ce3be766da55be807e0831 /web
parentf5e8b4093a1527967423a3af70f2b95d4b05008f (diff)
downloadplanetwars.dev-0f27ca80fbdb3366e047def628123d3cc8ca051c.tar.xz
planetwars.dev-0f27ca80fbdb3366e047def628123d3cc8ca051c.zip
prototype code upload
Diffstat (limited to 'web')
-rw-r--r--web/pw-server/src/routes/bots/[bot_id].svelte30
1 files changed, 29 insertions, 1 deletions
diff --git a/web/pw-server/src/routes/bots/[bot_id].svelte b/web/pw-server/src/routes/bots/[bot_id].svelte
index 90fd78d..1d7994d 100644
--- a/web/pw-server/src/routes/bots/[bot_id].svelte
+++ b/web/pw-server/src/routes/bots/[bot_id].svelte
@@ -6,7 +6,7 @@
const res = await fetch(`/api/bots/${page.params["bot_id"]}`, {
headers: {
"Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
+ "Authorization": `Bearer ${token}`,
},
});
@@ -27,8 +27,36 @@
<script lang="ts">
export let bot: object;
+
+ let files;
+
+ async function submitCode() {
+ console.log("click");
+ const token = get_session_token();
+
+ const formData = new FormData();
+ formData.append("File", files[0]);
+
+ const res = await fetch(`/api/bots/${bot["id"]}/upload`, {
+ method: "POST",
+ headers: {
+ // the content type header will be set by the browser
+ "Authorization": `Bearer ${token}`,
+ },
+ body: formData,
+ });
+
+ console.log(res.statusText);
+ }
</script>
<div>
{bot["name"]}
</div>
+
+
+<div>Upload code</div>
+<form on:submit|preventDefault={submitCode}>
+ <input type="file" bind:files/>
+ <button type="submit">Submit</button>
+</form> \ No newline at end of file