✨ Expose manager to web api
This commit is contained in:
parent
23c8f3884d
commit
d10e9a7088
4 changed files with 56 additions and 5 deletions
30
backend/__init__.py
Normal file
30
backend/__init__.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from bottle import request, response, Bottle
|
||||
from manager import Manager
|
||||
from json import dumps
|
||||
from pathlib import Path
|
||||
|
||||
manager = Manager()
|
||||
app = Bottle()
|
||||
|
||||
|
||||
@app.post("/video")
|
||||
def add_videos():
|
||||
manager.add_videos_by_number(request.json)
|
||||
return "OK"
|
||||
|
||||
|
||||
@app.get("/progress")
|
||||
def get_progress():
|
||||
response.content_type = "application/json"
|
||||
return dumps(manager.get_progress())
|
||||
|
||||
|
||||
@app.post("/download")
|
||||
def download():
|
||||
parent_dir = Path(request.json["parent_dir"])
|
||||
id = request.json["id"]
|
||||
try:
|
||||
manager.download(id, parent_dir)
|
||||
return "OK"
|
||||
except:
|
||||
return "Not ready"
|
Loading…
Add table
Add a link
Reference in a new issue