From c084dcc5d15129a513b7a5d11630e5d45d69048f Mon Sep 17 00:00:00 2001 From: eneller Date: Wed, 19 Mar 2025 19:17:27 +0100 Subject: [PATCH] feat: basic functionality --- src/core/views.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/views.py b/src/core/views.py index 1e915c2..c453186 100644 --- a/src/core/views.py +++ b/src/core/views.py @@ -25,12 +25,12 @@ def index(request: HttpRequest): targetParam = request.GET.get('t', None) if validateUrl(targetParam): - epub = getEpub(targetParam) - fname = os.path.join(settings.MEDIA_ROOT, epub) - file = open(fname, 'rb') + fpath = getEpub(targetParam) + fname = os.path.basename(fpath) + file = open(fpath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' - response['Content-Disposition'] = f'attachment; filename="{os.path.basename(fname)}"' + response['Content-Disposition'] = f'attachment; filename="{fname}"' return response return render(request, 'index.html', context) @@ -43,11 +43,8 @@ def validateUrl(param)->bool : return False +# TODO make this async and show some indication of progress/loading #@shared_task -def getEpub(param): - # TODO validate / sanitize input +def getEpub(book_url): # TODO check for existing file and age - #GBConvert(param,downloaddir=settings.MEDIA_ROOT).run() - # TODO redirect to loading page - # TODO redirect to download page - raise NotImplementedError + return converter.download(book_url)