Last active
May 19, 2018 10:15
-
-
Save Spazzy757/1b81ec7778fea51a2e95c7b06b291765 to your computer and use it in GitHub Desktop.
These are views that will open different types of files in new tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For displaying images in new tab: | |
def home(request): | |
image_data = open(“/path/to/my/image.png”, “rb”).read() | |
return HttpResponse(image_data, mimetype=”image/png”) | |
# For displaying pdf files in new tab: | |
def home(request): | |
image_data = open(“/path/to/my/image.pdf”, “rb”).read() | |
return HttpResponse(image_data, mimetype=”application/pdf”) | |
# For displaying videos in new tab: | |
def home(request): | |
image_data = open(“/path/to/my/image.mp4”, “rb”).read() | |
return HttpResponse(image_data, mimetype=”video/mp4″) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment