I'm trying (unsuccessfully) to pass command line paramters to a python program called by javascript XMLHTTPRequest. In my python program I have used each of sys.argv, getopt and argparse, all of which work when run from the command line but not when called from the Javascript script. In my Javascript program I have tried:
xhr.open('GET', 'https://solarpredictor.co.uk/test.py?solcast&full&graph', true);
xhr.open('GET', 'https://solarpredictor.co.uk/test.py?s=solcast&f=full&g=graph', true);
and
xhr.open('GET', 'https://solarpredictor.co.uk/test.py?solcast', true);
none of which work. In every case the parameters are not being found by the py program.
How can I get the python program to retrieve parameters when called within XMLHTTPRequest?
For what it is worth, this is my python program:
#!/usr/bin/python3
import sys
solcast = False
full = False
graph = True
print("len = ",len(sys.argv))
for x in range(1,len(sys.argv)):
param = sys.argv[x]
print(param)
if param == 'solcast':
solcast = not solcast
elif param == 'full':
full = not full
elif param == 'graph':
graph = not graph
print(solcast,full,graph)
test.pyscript?