markdown-up 1.6.4__tar.gz → 1.7.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-up
3
- Version: 1.6.4
3
+ Version: 1.7.0
4
4
  Summary: The MarkdownUp launcher
5
5
  Home-page: https://github.com/craigahobbs/markdown-up-py
6
6
  Author: Craig A. Hobbs
@@ -20,7 +20,7 @@ Classifier: Topic :: Utilities
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
22
  Requires-Dist: chisel>=1.0
23
- Requires-Dist: gunicorn>=21.0
23
+ Requires-Dist: waitress>=2.1
24
24
 
25
25
  # markdown-up
26
26
 
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = markdown-up
3
- version = 1.6.4
3
+ version = 1.7.0
4
4
  url = https://github.com/craigahobbs/markdown-up-py
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
@@ -27,7 +27,7 @@ package_dir =
27
27
  = src
28
28
  install_requires =
29
29
  chisel >= 1.0
30
- gunicorn >= 21.0
30
+ waitress >= 2.1
31
31
 
32
32
  [options.entry_points]
33
33
  console_scripts =
@@ -58,11 +58,11 @@ class MarkdownUpApplication(chisel.Application):
58
58
  self.add_request(markdown_up_index)
59
59
 
60
60
  def __call__(self, environ, start_response):
61
- request_method = environ.get('REQUEST_METHOD')
61
+ request_method = environ['REQUEST_METHOD']
62
62
  path_info = environ['PATH_INFO']
63
63
 
64
64
  # Chisel API request? Otherwise, its a static request...
65
- if request_method == 'GET' and path_info in ('/', '/markdown_up_index'):
65
+ if request_method == 'GET' and path_info in ('/', '/doc', '/doc/', '/doc/doc_index', '/doc/doc_request', '/markdown_up_index'):
66
66
  return super().__call__(environ, start_response)
67
67
 
68
68
  # Compute the static file path
@@ -149,6 +149,7 @@ MARKDOWN_UP_HTML = chisel.StaticRequest(
149
149
  'markdownText': `\\
150
150
  ~~~ markdown-script
151
151
  include 'https://craigahobbs.github.io/markdown-up/launcher/app.mds'
152
+
152
153
  markdownUpIndex()
153
154
  ~~~
154
155
  `
@@ -10,9 +10,9 @@ import os
10
10
  import webbrowser
11
11
 
12
12
  from schema_markdown import encode_query_string
13
- import gunicorn.app.base
13
+ import waitress
14
14
 
15
- from .app import MarkdownUpApplication
15
+ from .app import HTML_EXTS, MarkdownUpApplication
16
16
 
17
17
 
18
18
  def main(argv=None):
@@ -28,6 +28,8 @@ def main(argv=None):
28
28
  help='the application port (default is 8080)')
29
29
  parser.add_argument('-n', dest='no_browser', action='store_true',
30
30
  help="don't open a web browser")
31
+ parser.add_argument('-q', dest='quiet', action='store_true',
32
+ help="don't display access logging")
31
33
  args = parser.parse_args(args=argv)
32
34
 
33
35
  # Verify the path exists
@@ -46,46 +48,29 @@ def main(argv=None):
46
48
  if root == '':
47
49
  root = '.'
48
50
 
49
- # Define the server's when_ready function
51
+ # Construct the URL
50
52
  host = '127.0.0.1'
51
- def when_ready(_):
52
- # Do nothing?
53
- if args.no_browser:
54
- return
55
-
56
- # Construct the URL
57
- if is_file:
53
+ if is_file:
54
+ if args.path.endswith(HTML_EXTS):
55
+ url = f'http://{host}:{args.port}/{os.path.basename(args.path)}'
56
+ else:
58
57
  hash_args = encode_query_string({'url': os.path.basename(args.path)})
59
58
  url = f'http://{host}:{args.port}/#{hash_args}'
60
- else:
61
- url = f'http://{host}:{args.port}/'
59
+ else:
60
+ url = f'http://{host}:{args.port}/'
62
61
 
63
- # Launch the web browser
62
+ # Launch the web browser
63
+ if not args.no_browser:
64
64
  webbrowser.open(url)
65
65
 
66
- # Host the application
67
- StandaloneApplication(MarkdownUpApplication(root), {
68
- 'access_log_format': '%(h)s %(l)s "%(r)s" %(s)s %(b)s',
69
- 'accesslog': '-',
70
- 'errorlog': '-',
71
- 'bind': f'{host}:{args.port}',
72
- 'workers': 2,
73
- 'when_ready': when_ready
74
- }).run()
66
+ # Create the WSGI application
67
+ wsgiapp = MarkdownUpApplication(root)
68
+ def wsgiapp_wrap(environ, start_response):
69
+ if not args.quiet:
70
+ print(f'markdown-up: {environ["REQUEST_METHOD"]} {environ["PATH_INFO"]} {environ["QUERY_STRING"]}')
71
+ return wsgiapp(environ, start_response)
75
72
 
76
-
77
- # A stand-alone WSGI server using Gunicorn - see https://docs.gunicorn.org/en/stable/custom.html
78
- class StandaloneApplication(gunicorn.app.base.BaseApplication):
79
- # pylint: disable=abstract-method
80
-
81
- def __init__(self, application, options): # pragma: no cover
82
- self.options = options
83
- self.application = application
84
- super().__init__()
85
-
86
- def load_config(self): # pragma: no cover
87
- for key, value in self.options.items():
88
- self.cfg.set(key, value)
89
-
90
- def load(self): # pragma: no cover
91
- return self.application
73
+ # Host the application
74
+ if not args.quiet:
75
+ print(f'markdown-up: Serving at {url} ...')
76
+ waitress.serve(wsgiapp_wrap, port=args.port)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-up
3
- Version: 1.6.4
3
+ Version: 1.7.0
4
4
  Summary: The MarkdownUp launcher
5
5
  Home-page: https://github.com/craigahobbs/markdown-up-py
6
6
  Author: Craig A. Hobbs
@@ -20,7 +20,7 @@ Classifier: Topic :: Utilities
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
22
  Requires-Dist: chisel>=1.0
23
- Requires-Dist: gunicorn>=21.0
23
+ Requires-Dist: waitress>=2.1
24
24
 
25
25
  # markdown-up
26
26
 
@@ -0,0 +1,2 @@
1
+ chisel>=1.0
2
+ waitress>=2.1
@@ -1,2 +0,0 @@
1
- chisel>=1.0
2
- gunicorn>=21.0
File without changes
File without changes
File without changes