diff options
Diffstat (limited to 'web/pw-server/src/routes')
-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 |