?? ?????????? ????????? ????
????????
| | |
---|
??????
| |
---|
????????
| |
---|
??????????
| |
---|
??? ????? ???????? ???? ???? ????????
???????? ????????????
??????
-
????????
??? ?? ?? ?? ??? ??????? ?? ???? ???? ? ???? ????? ???? ???.
???? ???? ???????? ???????
?????????
????????? ?? ????? ????? ???????? ? ?????? ??????? ???? ?? ????? ????? ?????? ?? ???????? ?? ??? ??? ???:
setlocale
(
LC_ALL
,
"en_US.utf8"
);
header
(
"Content-Type: application/json"
);
header
(
"Access-Control-Allow-Origin: *"
);
$command
=
escapeshellcmd
(
"/usr/bin/python2.7 /data/project/YourAccount/pywikipedia/example.py"
);
$args
=
escapeshellarg
(
$_GET
[
"FirstArg"
])
.
" "
.
escapeshellarg
(
$_GET
[
"SecondArg"
]);
echo
shell_exec
(
$command
.
" "
.
$args
);
- ??? ???? ??????? ?? ????????
- ?? ????????? ?? ?????? ??? ?? ?? ????
example.py
??? ???????? ?????? ? ?? ?????
FirstArg
?
SecondArg
?? ?? ????? ?????? ??????.
- ?? ???????? ?? ???? ?? public_html ???? ???????? ?? wmflabs.org ???? ????.
- ?????? ?? ?? ??? ????
http://tools.wmflabs.org/YourAccount/example.php?FirstArg=test&SecondArg=test
????? ??? ?? ????????? ??? ????? ?? ?? ??? ????? ??????????? ?? ???????? ????? ????.
import
sys
,
json
result
=
{}
FirstArg
=
unicode
(
sys
.
argv
[
1
],
'UTF-8'
)
SecondArg
=
unicode
(
sys
.
argv
[
2
],
'UTF-8'
)
Text
=
run
(
faname
,
enname
,
result
)
result
[
'our_text'
]
=
Text
print
json
.
dumps
(
result
)
- ??? ???? ??????? ?? ??????
- ?? ???? ?? ?? ?? ?????? ??? ??? ?? ????? ???????? ???? ??????? ?? ????? ?? ??? ???????? ???? ?? ??? ???? ? ??? ????????? ???? ?? ?? ??? ????.
- ?????????
FirstArg
?
SecondArg
?????????? ????? ?? ?? ?????? ?? ?????? ????? ?? ????? ?????? ?? ????? ??????.
- ????
run()
????? ??? ?? ???? ?? ?? ?????? ???????? ?? ??? ????? ??? ??????.
- ????? ?? ?????? ?? ???? ????
.json
??? ?? ?? ?????? ???????? ?????? ? ????????? ?? ??? ????? ??????????? ????? ???? ?? ?? ?? ???? ?? ??????? ??? ????.