Download code_interpreters/languages/html.py from aiflows/InterpreterFlowModule: direct link, hf CLI and curl.
- Browser
- Download file 667 Bytes
-
https://huggingface.co/aiflows/InterpreterFlowModule/resolve/f5ba9f9afc5a4b5f9cc00ef80230b60bcc8bd9cc/code_interpreters/languages/html.py
- Command line
-
hf download hf://aiflows/InterpreterFlowModule@f5ba9f9afc5a4b5f9cc00ef80230b60bcc8bd9cc/code_interpreters/languages/html.py
-
curl -L -o html.py https://huggingface.co/aiflows/InterpreterFlowModule/resolve/f5ba9f9afc5a4b5f9cc00ef80230b60bcc8bd9cc/code_interpreters/languages/html.py
667 Bytes
| import webbrowser | |
| import tempfile | |
| import os | |
| from ..base_code_interpreter import BaseCodeInterpreter | |
| class HTML(BaseCodeInterpreter): | |
| file_extension = "html" | |
| proper_name = "HTML" | |
| def __init__(self): | |
| super().__init__() | |
| def run(self, code): | |
| # Create a temporary HTML file with the content | |
| with tempfile.NamedTemporaryFile(delete=False, suffix=".html") as f: | |
| f.write(code.encode()) | |
| # Open the HTML file with the default web browser | |
| webbrowser.open('file://' + os.path.realpath(f.name)) | |
| yield {"output": f"Saved to {os.path.realpath(f.name)} and opened with the user's default web browser."} |