Skip to content

Commit

Permalink
Merge pull request #792 from kmehant/fix-API-server
Browse files Browse the repository at this point in the history
Defined endpoints for file compression and added missing imports in sender.py
  • Loading branch information
vivonk authored Jul 29, 2019
2 parents 696ffd2 + 73967ef commit 42d4bc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/core/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ def serve_ui1():
# file sending endpoints
server.add_url_rule(rule='/api/file', endpoint='send_file_from_path', view_func=sender.send_file_from_path,
methods=['GET'])
server.add_url_rule(rule='/api/compress', endpoint='start_compression', view_func=sender.start_compression, methods=['POST'])
server.add_url_rule(rule='/api/compression-progress', endpoint='get_compression_progress', view_func=sender.check_compression_progress, methods=['GET'])
3 changes: 3 additions & 0 deletions components/core/file_sender/sender.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from flask import Response, request, send_file, jsonify
from DownloadManager import get_id_from_gid, get_download_path, get_download_name_from_id, get_compression_progress
import logging
import os
import subprocess
import json
from utils.token_utils import token_validator


Expand Down
4 changes: 2 additions & 2 deletions components/core/routes/Download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from utils.app_constants import SERVER_SECRET_KEY
from utils.token_utils import token_validator
from initializer import socketio

conf = get_conf_reader("dl.conf")

def start():
try:
Expand All @@ -33,7 +33,7 @@ def kill():
p.join()
jsonreq = json.dumps({'jsonrpc': '2.0', 'id': 'qwer', 'method': 'aria2.pauseAll'})
jsonreq = jsonreq.encode('ascii')
c = urllib.request.urlopen('http://localhost:6800/jsonrpc', jsonreq)
c = urllib.request.urlopen(conf['aria_server'], jsonreq)
if verbose:
print(c)
if not p.is_alive():
Expand Down

0 comments on commit 42d4bc6

Please sign in to comment.