问题
I've to tried to find out similar issue in stack overflow, but I couldn't. I am using python requests library to send POST request to my personal domain name www.****.com.
r = requests.post('http://www.****.com', data = {'temp1':"Anum"})
print r.text
When I run the script, the r.text shows me "Welcome Anum". Where I have written a small php script on my website
<?php
$data=$_POST["temp1"];
echo "Welcome ". $data. "<br />";
?>
Now the problem is, I am not able to see this get request on actual website, even after refreshing the page. I tried sending POST request in a loop after every 3 seconds, but still can't see any update on actual website. Do I need to loop up my php code to continuously listen for requests from client ? My understanding is that my domain name is working as Server and python script as client, so as the client send request to server, how do I manage my server to catch that request and display on web page ?
回答1:
I understand you want the python script to send a variable, which will be visible to other visitors of the website? You need to store the value which you recieve from python somewhere, like in a database. Then you can read that value and show it to the visitor.
来源:https://stackoverflow.com/questions/38999552/update-webpage-after-receiving-post-request