diff --git a/backend/__init__.py b/backend/__init__.py index 69c7e7f..56d77f8 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -1,12 +1,23 @@ -from bottle import request, response, Bottle, HTTPResponse +from bottle import request, response, Bottle, static_file from manager import Manager from json import dumps from pathlib import Path +from tkinter import filedialog as fd manager = Manager() app = Bottle() +@app.get("/") +def frontend(): + return static_file("index.html", root="frontend/dist") + + +@app.get("/") +def frontend(filepath): + return static_file(filepath, root="frontend/dist") + + @app.post("/video") def add_videos(): nvlist = request.json["nvlist"].split() @@ -20,8 +31,14 @@ def get_progress(): return dumps(manager.get_progress()) -@app.post("/download") +@app.get("/download") def download(): - parent_dir = Path(request.json["parent_dir"]) - manager.download(parent_dir) + manager.download() return "OK" + + +@app.get("/path") +def get_path(): + path = fd.askdirectory() + manager.path = path + return path diff --git a/frontend/src/views/AudioDownload.vue b/frontend/src/views/AudioDownload.vue index ef29dbf..6b2190f 100644 --- a/frontend/src/views/AudioDownload.vue +++ b/frontend/src/views/AudioDownload.vue @@ -57,14 +57,12 @@ const progress_info = computed(() => { }); function start_download() { - axios.post("http://localhost:8000/download", { - parent_dir: "/home/zhao/Desktop/tmp", - }); + axios.get("/download"); } onMounted(() => { setInterval(() => { - axios.get("http://localhost:8000/progress").then((resp) => { + axios.get("/progress").then((resp) => { state_list.value = resp.data; }); }, 200); diff --git a/frontend/src/views/InputVideoNumber.vue b/frontend/src/views/InputVideoNumber.vue index 942ecc6..5a8bf90 100644 --- a/frontend/src/views/InputVideoNumber.vue +++ b/frontend/src/views/InputVideoNumber.vue @@ -8,18 +8,38 @@ const nvlist = ref(""); const axios = inject("axios"); +const path = ref(""); + onMounted(() => { input.value.focus(); }); function sendNVList() { - axios.post("http://localhost:8000/video", { nvlist: nvlist.value }); + axios.post("/video", { nvlist: nvlist.value }); emit("change-stage"); } + +function get_path() { + axios.get("/path").then(({ data }) => { + path.value = data; + input.value.focus(); + }); +}