Update webpage after receiving POST request

岁酱吖の 提交于 2020-01-24 07:16:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!