Skip to content

Commit

Permalink
Add include to python
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbruno committed Nov 16, 2023
1 parent 0ac8961 commit 36aa359
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bigbashview/usr/lib/bbv/server/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def process_includes(self, html_content):
html_content = self.include_bash(html_content, include_content, match.group(0))
elif include_type == 'php':
html_content = self.include_php(html_content, include_content, match.group(0))
elif include_type == 'python':
html_content = self.include_python(html_content, include_content, match.group(0))
elif include_type == 'node':
html_content = self.include_node(html_content, include_content, match.group(0))

Expand Down Expand Up @@ -131,6 +133,14 @@ def include_php(self, html_content, script, original_string):
html_content = html_content.replace(original_string, f"Error executing PHP script: {e.output.decode()}")
return html_content

def include_python(self, html_content, script, original_string):
try:
result = subprocess.check_output(['python3', script], stderr=subprocess.STDOUT)
html_content = html_content.replace(original_string, result.decode())
except subprocess.CalledProcessError as e:
html_content = html_content.replace(original_string, f"Error executing Python script: {e.output.decode()}")
return html_content

def include_node(self, html_content, script, original_string):
try:
result = subprocess.check_output(['node', '-e', script], stderr=subprocess.STDOUT)
Expand Down

0 comments on commit 36aa359

Please sign in to comment.