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() manager.add_videos_by_number(nvlist) return "OK" @app.get("/progress") def get_progress(): response.content_type = "application/json" return dumps(manager.get_progress()) @app.get("/download") def download(): manager.download() return "OK" @app.get("/path") def get_path(): path = fd.askdirectory() manager.path = path return path