I am just trying out a few things in Html, and I am very new to it. I tried to write a Html code that takes in input a string and calls a python script to find the frequency of all unicode characters in string. When I am running my html script, it tries to open gedit and show my python script, instead of running the script. How do I run the script, providing my arguments to it during the process?
This is my python code :
import cgi
import cgitb
cgitb.enable()
#input_str=input("Enter the string\n")
def Frequency_match(input_str):
flag=0
count=0
i=0
j=0
#print("Here\n")
while i < len(input_str):
#print("The current value of i is ",i,"\n")
count=0
j=0
while j < len(input_str):
if input_str[i]==input_str[j]:
if j<i:
flag=1
else:
count+=1
j+=1
if flag==0:
print("The frequency of ",i," ",input_str[i],"is",count,"\n")
i+=1
#print("The value of i is ",i,"\n")
flag=0
form = cgi.FieldStorage()
input_str = form.getvalue('input_str')
Frequency_match(input_str)
<!DOCTYPE html>
<html>
<body>
<form action="./NLP_test.py" method="post">
Input String: <input type="text" name="input_str"><br>
<input type="submit" value="run_script" "/>
</form>
<p>Click on the submit button, and the input will be sent to a page on the server called "/NLP_test.py ".</p>
</body>
</html>
When I run the html script, I get asked if I want to open the python file in text editor