Add support for sharing .stls

This commit is contained in:
rmgr 2022-02-17 12:05:33 +10:30
parent 68709c850e
commit c68a4af4b1
1 changed files with 10 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import http.server
import socketserver
import shutil
list_of_tags = {}
copy_extensions = [".gif",".jpg",".png", ".html"]
copy_extensions = [".gif",".jpg",".png", ".html", ".stl"]
output_dir = ""
base_url = ""
@ -211,12 +211,18 @@ def process_tag(output, page_title, parent_link, base_dir , tag_text):
def process_link(output, link_text):
link_text = link_text.replace(":","/")
link_path = os.path.join(base_url, link_text)
if not "|" in link_text:
output.write('<a href="' + os.path.join(base_url,link_text) + '.html">' + link_text + '</a>')
if os.path.splitext(link_text) in copy_extensions:
output.write('<a href="' + os.path.join(base_url,link_text) + '">' + link_text + '</a>')
else:
output.write('<a href="' + os.path.join(base_url,link_text) + '.html">' + link_text + '</a>')
else:
split_link = link_text.split("|")
output.write('<a href="' + os.path.join(base_url, split_link[0]) + '.html">' + split_link[1] + '</a>')
if os.path.splitext(split_link[0].rstrip())[1] in copy_extensions:
output.write('<a href="' + os.path.join(base_url,split_link[0]) + '">' + split_link[1] + '</a>')
else:
output.write('<a href="' + os.path.join(base_url,split_link[0]) + '.html">' + split_link[1] + '</a>')
def process_external_link(output, link_text):
output.write('<a href="' + link_text + '">' + link_text + '</a>')