I have node installed on my server. I want to execute a JavaScript file that basically takes some information from a Django model. How could I pass JSON and large textarea variables into my node script from inside Django?
class Page(models.Model):
html = models.TextField(blank = True, null = True)
less = models.TextField(blank = True, null = True)
context = models.TextField(blank = True, null = True)
def render(self):
# pass context (converted to JSON), less and html to node script and compile.
# How to do this?
Thanks!
Here is how I was able to do this:
import subprocess
...
command_list = ['node', 'static/js/node_script.js']
try:
output = subprocess.check_output(command_list)
except subprocess.CalledProcessError:
output = "Error in command_list."