Created
September 9, 2021 09:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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