Skip to content

Commit

Permalink
url decode support
Browse files Browse the repository at this point in the history
  • Loading branch information
treatmesubj committed Mar 2, 2023
1 parent 101c672 commit 35ad550
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions httpmdhtml/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ class md_to_html_SimpleHTTPRequestHandler(SimpleHTTPRequestHandler):
def __init__(self, *args, MarkdownIt_obj=None, **kwargs):
self.MarkdownIt_obj = MarkdownIt_obj
super().__init__(*args, **kwargs)
self.url_decoded_path = urllib.parse.unquote(self.path)


def do_GET(self, rm_temp_html=False):
"""Serve a GET request."""
if self.path.endswith(".md") and os.path.exists(os.path.join(self.directory, f".{self.path}")): # check for markdown file request
in_file_path=os.path.join(self.directory, f".{self.path}")
out_file_path=os.path.join(self.directory, f".{os.path.splitext(self.path)[0]}.html")
self.url_dc_path = urllib.parse.unquote(urllib.parse.urlsplit(self.path).path) # url decode, strip query params for file check
if self.url_dc_path.endswith(".md") and os.path.exists(os.path.join(self.directory, f".{self.url_dc_path}")): # check for markdown file request
in_file_path=os.path.join(self.directory, f".{self.url_dc_path}")
out_file_path=os.path.join(self.directory, f".{os.path.splitext(self.url_dc_path)[0]}.html")
md_to_html.markdown_to_html(
self.MarkdownIt_obj,
in_file_path=in_file_path,
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ requires-dist =
beautifulsoup4
html5lib

description-file = README.md
long_description = file: README.md
long_description_content_type = text/markdown
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from setuptools import setup
setup(
name="httpmdhtml",
version="0.0.2",
version="0.0.3",
license="gpl-3.0",
author="John Hupperts",
author_email="[email protected]",
url="https://github.com/treatmesubj/python-md-to-html-server",
download_url="https://github.com/treatmesubj/python-md-to-html-server/archive/refs/tags/v0.0.2.tar.gz",
download_url="https://github.com/treatmesubj/python-md-to-html-server/archive/refs/tags/v0.0.3.tar.gz",
packages=["httpmdhtml"],
package_dir={"python-md-to-html-server": "httpmdhtml"},
project_urls={
Expand Down

0 comments on commit 35ad550

Please sign in to comment.