-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from joegasewicz/filetypes-#93
#93 content-type should be set based on filetypes
- Loading branch information
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import Any | ||
|
||
|
||
IMAGE_FILETYPE = ( | ||
"jpg", | ||
"jpeg", | ||
"png", | ||
"gif", | ||
"tiff", | ||
"svg+xml", | ||
"x-icon", | ||
) | ||
|
||
TXT_FILETYPE = ( | ||
"css", | ||
"csv", | ||
"html", | ||
"javascript", | ||
"plain", | ||
"xml", | ||
) | ||
|
||
VIDEO_FILETYPE = ( | ||
"mpeg", | ||
"mp4", | ||
"quicktime", | ||
"webm", | ||
"x-ms-wmv", | ||
"x-msvideo", | ||
"x-flv", | ||
) | ||
|
||
AUDIO_FILETYPE = ( | ||
"mpeg", | ||
"x-ms-wma", | ||
"vnd.rn-realaudio", | ||
"x-wav", | ||
) | ||
|
||
|
||
class StaticFiles: | ||
response: Any # Response | ||
mimetypes: str | ||
|
||
def __init__(self, response: Any, mimetype: str): | ||
self.response = response | ||
self.mimetype = mimetype | ||
|
||
def set_headers(self, file_type: str) -> None: | ||
self.response.set_headers({"Content-Type": f"{self.mimetype}/{file_type}"}) |
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