Javascript Integration with Docker

yum install httpd
systemctl disable firewalld
setenforce 0
systemctl start httpd
cd /var/www/html
gedit <file_Name>.html
<script>
function lw()
{

var xhr=new XMLHttpRequest();
i=document.getElementById("in1").value;

xhr.open("GET","http://192.168.43.104/cgi-bin/lw.py?x="+i,true);
xhr.send();

xhr.onload=function (){
var output=xhr.responseText;
document.getElementById("d1").innerHTML=output;
}
}

</script>
cd /var/www/cgi-bin
gedit <file_Name.py>
#!/usr/bin/python3
import cgi
import subprocess
import time
print("content-type: text/html")
print()
print("Hello from backend")
print()
f=cgi.FieldStorage()
cmd=f.getvalue("x")
o=subprocess.getoutput("sudo "+ cmd)
print(o)
vim /etc/group
vim /etc/sudoers
chmod +x <file_name>.py
http://<IP Address>/<file_Name>.html

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store