from bottle import request, response, Bottle, static_file from manager import Manager from json import dumps from queue import SimpleQueue manager = Manager() app = Bottle() action_queue = SimpleQueue() path_queue = SimpleQueue() @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.post("/path") def get_path(): path = request.json["path"] action_queue.put(path) manager.path = path_queue.get() return manager.path