markdown-up 1.6.5__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.5
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.5
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
@@ -10,7 +10,7 @@ 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
15
  from .app import HTML_EXTS, MarkdownUpApplication
16
16
 
@@ -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,49 +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:
58
- if args.path.endswith(HTML_EXTS):
59
- url = f'http://{host}:{args.port}/{os.path.basename(args.path)}'
60
- else:
61
- hash_args = encode_query_string({'url': os.path.basename(args.path)})
62
- url = f'http://{host}:{args.port}/#{hash_args}'
53
+ if is_file:
54
+ if args.path.endswith(HTML_EXTS):
55
+ url = f'http://{host}:{args.port}/{os.path.basename(args.path)}'
63
56
  else:
64
- url = f'http://{host}:{args.port}/'
57
+ hash_args = encode_query_string({'url': os.path.basename(args.path)})
58
+ url = f'http://{host}:{args.port}/#{hash_args}'
59
+ else:
60
+ url = f'http://{host}:{args.port}/'
65
61
 
66
- # Launch the web browser
62
+ # Launch the web browser
63
+ if not args.no_browser:
67
64
  webbrowser.open(url)
68
65
 
69
- # Host the application
70
- StandaloneApplication(MarkdownUpApplication(root), {
71
- 'access_log_format': '%(h)s %(l)s "%(r)s" %(s)s %(b)s',
72
- 'accesslog': '-',
73
- 'errorlog': '-',
74
- 'bind': f'{host}:{args.port}',
75
- 'workers': 2,
76
- 'when_ready': when_ready
77
- }).run()
78
-
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)
79
72
 
80
- # A stand-alone WSGI server using Gunicorn - see https://docs.gunicorn.org/en/stable/custom.html
81
- class StandaloneApplication(gunicorn.app.base.BaseApplication):
82
- # pylint: disable=abstract-method
83
-
84
- def __init__(self, application, options): # pragma: no cover
85
- self.options = options
86
- self.application = application
87
- super().__init__()
88
-
89
- def load_config(self): # pragma: no cover
90
- for key, value in self.options.items():
91
- self.cfg.set(key, value)
92
-
93
- def load(self): # pragma: no cover
94
- 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.5
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