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.
Files changed (19) hide show
  1. {markdown_up-1.9.1/src/markdown_up.egg-info → markdown_up-1.9.2}/PKG-INFO +1 -1
  2. {markdown_up-1.9.1 → markdown_up-1.9.2}/setup.cfg +1 -1
  3. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/app.py +21 -12
  4. {markdown_up-1.9.1 → markdown_up-1.9.2/src/markdown_up.egg-info}/PKG-INFO +1 -1
  5. {markdown_up-1.9.1 → markdown_up-1.9.2}/LICENSE +0 -0
  6. {markdown_up-1.9.1 → markdown_up-1.9.2}/README.md +0 -0
  7. {markdown_up-1.9.1 → markdown_up-1.9.2}/pyproject.toml +0 -0
  8. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/__init__.py +0 -0
  9. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/__main__.py +0 -0
  10. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/main.py +0 -0
  11. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/__init__.py +0 -0
  12. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/index.html +0 -0
  13. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/markdown-up.tar.gz +0 -0
  14. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up/static/markdownUpIndex.bare +0 -0
  15. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/SOURCES.txt +0 -0
  16. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/dependency_links.txt +0 -0
  17. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/entry_points.txt +0 -0
  18. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/requires.txt +0 -0
  19. {markdown_up-1.9.1 → markdown_up-1.9.2}/src/markdown_up.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: markdown-up
3
- Version: 1.9.1
3
+ Version: 1.9.2
4
4
  Summary: The MarkdownUp launcher
5
5
  Home-page: https://github.com/craigahobbs/markdown-up-py
6
6
  Author: Craig A. Hobbs
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = markdown-up
3
- version = 1.9.1
3
+ version = 1.9.2
4
4
  url = https://github.com/craigahobbs/markdown-up-py
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
@@ -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
- # Static response
103
- start_response(f'{status.value} {status.phrase}', [('Content-Type', content_type)])
104
- return [content]
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 = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: markdown-up
3
- Version: 1.9.1
3
+ Version: 1.9.2
4
4
  Summary: The MarkdownUp launcher
5
5
  Home-page: https://github.com/craigahobbs/markdown-up-py
6
6
  Author: Craig A. Hobbs
File without changes
File without changes
File without changes