MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / getContentType

Method getContentType

src/Ui/UiRequest.py:185–203  ·  view source on GitHub ↗
(self, file_name)

Source from the content-addressed store, hash-verified

183
184 # Get mime by filename
185 def getContentType(self, file_name):
186 file_name = file_name.lower()
187 ext = file_name.rsplit(".", 1)[-1]
188
189 if ext == "css": # Force correct css content type
190 content_type = "text/css"
191 elif ext == "js": # Force correct javascript content type
192 content_type = "text/javascript"
193 elif ext == "json": # Correct json header
194 content_type = "application/json"
195 elif ext in ("ttf", "woff", "otf", "woff2", "eot"):
196 content_type = "application/font"
197 else:
198 content_type = mimetypes.guess_type(file_name)[0]
199
200 if not content_type:
201 content_type = "application/octet-stream"
202
203 return content_type.lower()
204
205 # Return: <dict> Posted variables
206 def getPosted(self):

Callers 4

routeMethod · 0.95
actionWrapperMethod · 0.95
actionFileMethod · 0.95
actionSiteMediaMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected