fix: path problem when using local file

pull/24/head
hanchchch 1 year ago
parent 492c1afc91
commit 0568f5b42d

@ -1,5 +1,7 @@
import os
import uuid
import shutil
from pathlib import Path
from enum import Enum
from typing import Dict
import requests
@ -74,6 +76,10 @@ class FileHandler:
try:
if url.startswith(settings["SERVER"]):
local_filename = url[len(settings["SERVER"]) + 1 :]
shutil.copy(
local_filename,
Path(settings["PLAYGROUND_DIR"]) / Path(local_filename),
)
else:
local_filename = self.download(url)
return self.handlers[FileType.from_url(url)].handle(local_filename)

@ -1,4 +1,9 @@
const setAnswer = (answer) => {
document.getElementById("answer").textContent = answer;
};
const submit = async () => {
setAnswer("Loading...");
const files = [];
const rawfiles = document.getElementById("files").files;
@ -31,7 +36,7 @@ const submit = async () => {
});
const { answer } = await response.json();
document.getElementById("answer").textContent = answer;
setAnswer(answer);
};
const setRandomSessionId = () => {

Loading…
Cancel
Save