from django_downloadview import StorageDownloadView from django.core.files.storage import FileSystemStorage from django.contrib.auth.mixins import LoginRequiredMixin import os, tempfile, zipfile from wsgiref.util import FileWrapper from matplotlib.image import imsave from scipy.misc import toimage import datetime import uuid from django.utils import timezone import imageio import random from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger storage = FileSystemStorage() static_path = StorageDownloadView.as_view(storage=storage) '''import matplotlib.pyplot as plt plt.imshow(matrix) #Needs to be in row,col order plt.savefig(filename)''' @login_required def index(request): text = 'Hello, I' 'm WADO service' context = {'text': text} return render(request, 'index.html', context) @login_required def search(request): series = []
import os from django.conf import settings from django.core.files.storage import FileSystemStorage from django_downloadview import StorageDownloadView from django_downloadview.apache import x_sendfile storage_dir = os.path.join(settings.MEDIA_ROOT, "apache") storage = FileSystemStorage(location=storage_dir, base_url="".join([settings.MEDIA_URL, "apache/"])) optimized_by_middleware = StorageDownloadView.as_view(storage=storage, path="hello-world.txt") optimized_by_decorator = x_sendfile( StorageDownloadView.as_view(storage=storage, path="hello-world.txt"), source_url=storage.base_url, destination_dir="/apache-optimized-by-decorator/", )
import os from django.conf import settings from django.core.files.storage import FileSystemStorage from django_downloadview import StorageDownloadView from django_downloadview.apache import x_sendfile storage_dir = os.path.join(settings.MEDIA_ROOT, 'apache') storage = FileSystemStorage(location=storage_dir, base_url=''.join([settings.MEDIA_URL, 'apache/'])) optimized_by_middleware = StorageDownloadView.as_view(storage=storage, path='hello-world.txt') optimized_by_decorator = x_sendfile( StorageDownloadView.as_view(storage=storage, path='hello-world.txt'), source_url=storage.base_url, destination_dir='/apache-optimized-by-decorator/')
from django.core.files.storage import FileSystemStorage from django_downloadview import StorageDownloadView storage = FileSystemStorage() #: Serve file using ``path`` argument. static_path = StorageDownloadView.as_view(storage=storage) class DynamicStorageDownloadView(StorageDownloadView): """Serve file of storage by path.upper().""" def get_path(self): """Return uppercase path.""" return super(DynamicStorageDownloadView, self).get_path().upper() dynamic_path = DynamicStorageDownloadView.as_view(storage=storage)