How to turn a dot file in html using python?

Hi there!

I have a dot file and wanted to use python to automate it so it generates a graph in html. i was wondering if that’s possible to do and if anyone has an example i could look/learn from.

Thanks in advance!

I’m not sure what in html means here.
Most browsers (chrome, safari, …) can display files in svg, png or jpeg formats (along with others). Is that good enough?

sorry, since english isn’t my first language i do quite struggle with expressing myself.

what i meant is basically having a dot file with the whole infrastructure info of a company and it generates (with the help of python for automation) a graph with html

that’s how my supervisor put it out:


hope this one helps out and if not that’s also okay still appreciate your effort

Here is a link to the commonly-used Graphviz / Python library
Does this help?

I have the same question as Steve. But if you just want something approximating your workflow diagram:

import pathlib
import subprocess
import sys

dot = sys.argv[1]
png = f"{dot}.png"

subprocess.check_call(["dot", "-Tpng", "-o", png, dot])

html = pathlib.Path("my_html.html")
html.write_text(f'<html><body><img src="{png}"/></body></html>\n',