Was looking at this link 
https://www.geeksforgeeks.org/python-subprocess-module-to-execute-programs-written-in-different-languages/
 and 
am trying to translate it into Django.

Upon form submission from index.html in templates, I want to call the view 
function to run HelloWorld.java (in same directory as the admin, apps, 
models, etc files) and return the result onto the webpage.

So the form code would be something like

<form action="{% url path.to.request_page %}" method="POST">
    <input id="submit" type="button" value="Click" /></form>

The view function (same as from the link)

import subprocess

def executeJava(): 
  
    s = subprocess.check_output("javac HelloWorld.java;java HelloWorld", 
shell = True) 
    print(s.decode("utf-8")) 


How do I translate the driver function into Django? Insert into a function 
in views similar to this?

def form_submit(request):
if request.method == 'POST'
executeJava()
return render(request, 'templates/index.html')

Do I have to map this into urls.py? If so, how?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65ead62a-d2e3-4655-87c2-4077d9d0baf2o%40googlegroups.com.

Reply via email to