收到POST请求后更新网页

编程入门 行业动态 更新时间:2024-10-25 14:26:06
本文介绍了收到POST请求后更新网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经尝试找出堆栈溢出中的类似问题,但是我做不到.我正在使用python请求库将POST请求发送到我的个人域名www.****.

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.****.

r = requests.post('www.****', data = {'temp1':"Anum"}) print r.text

当我运行脚本时,r.text显示"Welcome Anum".我在网站上写了一个小的php脚本的地方

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 />"; ?>

现在的问题是,即使刷新页面后,我也无法在实际网站上看到此获取请求.我尝试每3秒循环发送一次POST请求,但在实际网站上仍然看不到任何更新.我是否需要循环我的php代码以持续侦听来自客户端的请求? 我的理解是,我的域名用作服务器,而python脚本用作客户端,因此当客户端向服务器发送请求时,如何管理服务器以捕获该请求并显示在网页上?

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 ?

推荐答案

我了解您希望python脚本发送一个变量,该变量对网站的其他访问者可见吗? 您需要将从python接收到的值存储在某个地方,例如存储在数据库中.然后,您可以读取该值并将其显示给访问者.

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.

更多推荐

收到POST请求后更新网页

本文发布于:2023-10-10 01:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1477321.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网页   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!