Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending data from python to php using post/get requests [duplicate]

Tags:

python

post

php

get

i need to send this file path /Users/bob/Documents/python_stuff/venv/json_output.json to the php page of http://localhost:8888/demo/display_data.php

My python code:

url = 'http://localhost:8888/demo/display_data.php'
file_path_json = {"1": "/Users/bob/Documents/python_stuff/venv/json_output.json"}
resp = requests.post(url, params=file_path_json)

php code:

$json_path['1'] = $_GET['1']; 

I do not know why it is not working. I have installed the requests module.

like image 708
bob Avatar asked Mar 20 '26 22:03

bob


1 Answers

I have tried following code on my PC and it's working for me

import requests

url = 'http://localhost/dx/index.php'
file_path_json = {"1": "/Users/bob/Documents/python_stuff/venv/json_output.json"}
resp = requests.post(url, file_path_json)
print(resp)

hope this helps

like image 58
Rajinder Avatar answered Mar 23 '26 10:03

Rajinder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!