In my phpcode
<?php
$out = array();
$execute='./test.py';
$name = "?key=1234&path=host";
exec ("$execute $name", $out);
foreach ($out as $value) {
echo "$value<br />\n";
}
?>
In test.py file i want to get the value corresponding to path
that is host
In test.py
#!c:/Python27/python.exe -u
import django
import cgi, cgitb, os, sys
cgitb.enable(); # formats errors in HTML
def get_full_path(self):
url = self.request.get_full_path('')
def query_splitter(url):
queries = url.split('?')[-1].split('&')
return dict([item.split('=') for item in queries])
print query_splitter(url).get('path')
but i get an error
<type 'exceptions.NameError'> Python 2.7.1: C:\Python27\python.exe
Thu Jan 27 13:57:45 2011
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
C:\wamp\bin\apache\Apache2.2.11\cgi-bin\showfields.py in ()
7 url = self.request.get_full_path('')
8 def query_splitter(url):
9 queries = url.split('?')[-1].split('&')
10 return dict([item.split('=') for item in queries])
=> 11 print query_splitter(url).get('path')
query_splitter = <function query_splitter>, url undefined
<type 'exceptions.NameError'>: name 'url' is not defined
args = ("name 'url' is not defined",)
message = "name 'url' is not defined"
Iam using django module...
i want to get the value corresponding to path for that what module i what to use?
and which python funcion i want to use?