feat: basic functionality
This commit is contained in:
@@ -25,12 +25,12 @@ def index(request: HttpRequest):
|
|||||||
|
|
||||||
targetParam = request.GET.get('t', None)
|
targetParam = request.GET.get('t', None)
|
||||||
if validateUrl(targetParam):
|
if validateUrl(targetParam):
|
||||||
epub = getEpub(targetParam)
|
fpath = getEpub(targetParam)
|
||||||
fname = os.path.join(settings.MEDIA_ROOT, epub)
|
fname = os.path.basename(fpath)
|
||||||
file = open(fname, 'rb')
|
file = open(fpath, 'rb')
|
||||||
response = FileResponse(file)
|
response = FileResponse(file)
|
||||||
response['Content-Type'] = 'application/octet-stream'
|
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 response
|
||||||
|
|
||||||
return render(request, 'index.html', context)
|
return render(request, 'index.html', context)
|
||||||
@@ -43,11 +43,8 @@ def validateUrl(param)->bool :
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# TODO make this async and show some indication of progress/loading
|
||||||
#@shared_task
|
#@shared_task
|
||||||
def getEpub(param):
|
def getEpub(book_url):
|
||||||
# TODO validate / sanitize input
|
|
||||||
# TODO check for existing file and age
|
# TODO check for existing file and age
|
||||||
#GBConvert(param,downloaddir=settings.MEDIA_ROOT).run()
|
return converter.download(book_url)
|
||||||
# TODO redirect to loading page
|
|
||||||
# TODO redirect to download page
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|||||||
Reference in New Issue
Block a user