here is my python file
import sys
import requests
wrapper = "[Python Storage LogReader v2.b001] "
log = {}
log_lines = sys.argv
index = 0
for line in log_lines[1:]:
error_log = wrapper + line
log[index] = error_log
index += 1
package = {}
package['test1'] = 'A'
package['test2'] = 'B'
package['log'] = log
success = requests.post('http://localhost:3000/post.php', package, False)
I call it like this:
python LogReader.py hello world sample
And the output received as the $_POST
array is this:
Array (
[test1] => A
[test2] => B
[log] => 2
)
Where "2" is the binary count of the arguments passed (I've verified by changing the argument count). What I want is this:
Array (
[test1] => A
[test2] => B
[log] => Array (
[0] => hello
[1] => world
[2] => sample
)
)
I am new to Python but familiar with PHP and the way it parses a $_POST
string. Essentially what I'm looking to send is this:
test1=A&test2=B&log[]=hello&log[]=world&log[]=sample
How do I do this in Python so as to get the equivalent? Obviously my goal is the simplest way possible. Thanks.