markdown-up 1.9.1__tar.gz → 1.9.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {markdown_up-1.9.1/src/markdown_up.egg-info → markdown_up-1.9.2}/PKG-INFO +1 -1
- {markdown_up-1.9.1 → markdown_up-1.9.2}/setup.cfg +1 -1
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/app.py +21 -12
- {markdown_up-1.9.1 → markdown_up-1.9.2/src/markdown_up.egg-info}/PKG-INFO +1 -1
- {markdown_up-1.9.1 → markdown_up-1.9.2}/LICENSE +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/README.md +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/pyproject.toml +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/__init__.py +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/__main__.py +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/main.py +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/__init__.py +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/index.html +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/markdown-up.tar.gz +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/markdownUpIndex.bare +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/SOURCES.txt +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/dependency_links.txt +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/entry_points.txt +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/requires.txt +0 -0
- {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
The MarkdownUp launcher back-end application
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import hashlib
|
|
8
9
|
from http import HTTPStatus
|
|
9
10
|
import importlib.resources
|
|
10
11
|
import os
|
|
@@ -88,20 +89,28 @@ class MarkdownUpApplication(chisel.Application):
|
|
|
88
89
|
|
|
89
90
|
# Read the static file
|
|
90
91
|
with open(path, 'rb') as path_file:
|
|
91
|
-
status = HTTPStatus.OK
|
|
92
92
|
content = path_file.read()
|
|
93
|
-
except FileNotFoundError:
|
|
94
|
-
status = HTTPStatus.NOT_FOUND
|
|
95
|
-
content = status.phrase.encode(encoding='utf-8')
|
|
96
|
-
content_type = 'text/plain; charset=utf-8'
|
|
97
|
-
except: # pylint: disable=bare-except
|
|
98
|
-
status = HTTPStatus.INTERNAL_SERVER_ERROR
|
|
99
|
-
content = status.phrase.encode(encoding='utf-8')
|
|
100
|
-
content_type = 'text/plain; charset=utf-8'
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
# Compute the etag
|
|
95
|
+
md5 = hashlib.md5()
|
|
96
|
+
md5.update(content)
|
|
97
|
+
etag = md5.hexdigest()
|
|
98
|
+
|
|
99
|
+
# Check the etag - is the resource modified?
|
|
100
|
+
if etag == environ.get('HTTP_IF_NONE_MATCH'):
|
|
101
|
+
status = HTTPStatus.NOT_MODIFIED
|
|
102
|
+
start_response(f'{status.value} {status.phrase}', [])
|
|
103
|
+
return []
|
|
104
|
+
|
|
105
|
+
# Respond with static content
|
|
106
|
+
status = HTTPStatus.OK
|
|
107
|
+
start_response(f'{status.value} {status.phrase}', [('Content-Type', content_type), ('ETag', etag)])
|
|
108
|
+
return [content]
|
|
109
|
+
|
|
110
|
+
except: # pylint: disable=bare-except
|
|
111
|
+
status = HTTPStatus.NOT_FOUND
|
|
112
|
+
start_response(f'{status.value} {status.phrase}', [('Content-Type', 'text/plain; charset=utf-8')])
|
|
113
|
+
return [status.phrase.encode(encoding='utf-8')]
|
|
105
114
|
|
|
106
115
|
|
|
107
116
|
_CONTENT_TYPES = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|