diff --git a/web_viewer.py b/web_viewer.py new file mode 100644 index 0000000..3cef61b --- /dev/null +++ b/web_viewer.py @@ -0,0 +1,59 @@ +class WebViewer: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "url": ("STRING", { + "multiline": False, + "default": "https://nofun.io" + }), + "width": ("INT", { + "default": 800, + "min": 100, + "max": 2000, + "step": 10 + }), + "height": ("INT", { + "default": 600, + "min": 100, + "max": 2000, + "step": 10 + }) + } + } + + RETURN_TYPES = () + FUNCTION = "view_webpage" + CATEGORY = "Web" + + def view_webpage(self, url, width, height): + import webbrowser + import tempfile + import os + + html_content = f""" + +
+ + + + """ + + # Create a temporary HTML file + with tempfile.NamedTemporaryFile(delete=False, suffix='.html', mode='w') as f: + f.write(html_content) + temp_path = f.name + + # Open the temporary file in the default browser + webbrowser.open('file://' + os.path.abspath(temp_path)) + + return () + +# Register the node +NODE_CLASS_MAPPINGS = { + "WebViewer": WebViewer +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "WebViewer": "Web Viewer" +} \ No newline at end of file