diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-30 23:41:47 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-30 23:41:47 +0100 |
commit | 0f27ca80fbdb3366e047def628123d3cc8ca051c (patch) | |
tree | 8363206692757f92e4ce3be766da55be807e0831 /web/pw-server | |
parent | f5e8b4093a1527967423a3af70f2b95d4b05008f (diff) | |
download | planetwars.dev-0f27ca80fbdb3366e047def628123d3cc8ca051c.tar.xz planetwars.dev-0f27ca80fbdb3366e047def628123d3cc8ca051c.zip |
prototype code upload
Diffstat (limited to 'web/pw-server')
-rw-r--r-- | web/pw-server/src/routes/bots/[bot_id].svelte | 30 |
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 |