Skip to content

Instantly share code, notes, and snippets.

@YashIndane
Created September 9, 2021 09:33
Show Gist options
  • Save YashIndane/d11dc851d649e2e42256708ffdfa5bff to your computer and use it in GitHub Desktop.
Save YashIndane/d11dc851d649e2e42256708ffdfa5bff to your computer and use it in GitHub Desktop.
This is a sample code on how to receive data from a form (HTML). The `name` has the command and that is run and output is printed along with status.
#!/usr/bin/python3
import cgi
import subprocess
print('content-type:text/html')
print()
form_values = cgi.FieldStorage()
data = form_values.getvalue("name")
output = subprocess.getstatusoutput(data)
print(output[0], output[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment