diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-20 15:55:48 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-20 15:55:48 +0200 |
commit | d257c974a8acea9d7309b63c829fefcbfb47d831 (patch) | |
tree | e953bce501c941e7a6c0dbb63b97e5c94c267aad /module/web/WebServer.py | |
parent | netload fix (diff) | |
download | pyload-d257c974a8acea9d7309b63c829fefcbfb47d831.tar.xz |
dynamic status bar
Diffstat (limited to 'module/web/WebServer.py')
-rw-r--r-- | module/web/WebServer.py | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/module/web/WebServer.py b/module/web/WebServer.py index 5885ab2de..074ab4242 100644 --- a/module/web/WebServer.py +++ b/module/web/WebServer.py @@ -146,8 +146,6 @@ def get_links(): downloads = core.get_downloads() - - for dl in downloads: json += '{' json += '"id": "%s", "name": "%s", "speed": "%s", "eta": "%s", "kbleft": "%s", "size": "%s", "percent": "%s", "wait": "%s", "status": "%s"'\ @@ -160,6 +158,40 @@ def get_links(): json += "] }" return json +@route('/json/status') +def get_status(): + response.header['Cache-Control'] = 'no-cache, must-revalidate' + response.content_type = 'application/json' + + if not check_auth(request): + abort(404, "No Access") + + data = core.server_status() + + if data['pause']: + status = "paused" + else: + status = "running" + + json = '{ "status": "%s", "speed": "%s", "queue": "%s" }' % (status, str(int(data['speed'])), str(data['queue'])) + + return json + +@route('/json/addlinks', method='POST') +def add_links(): + response.header['Cache-Control'] = 'no-cache, must-revalidate' + response.content_type = 'application/json' + + if not check_auth(request): + abort(404, "No Access") + + links = request.POST['links'].split('\n') + + core.add_links(links) + + return "{}" + + @route('/favicon.ico') def favicon(): |