newmediamonitoring/polls/views/download.py

17 lines
601 B
Python

import os
from django.conf import settings
from django.http import HttpResponse, Http404
from django.shortcuts import render
def app_intro(request):
return render(request, 'polls/app.html')
def download(request):
file_path = os.path.join(settings.MEDIA_ROOT, 'pom.apk')
if os.path.exists(file_path):
with open(file_path, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="application/vnd.android.package-archive")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404