Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将python cgi脚本包含到html页面中_Python_Html_Cgi - Fatal编程技术网

如何将python cgi脚本包含到html页面中

如何将python cgi脚本包含到html页面中,python,html,cgi,Python,Html,Cgi,我想在html网页上显示到值。我有一个Python CGI脚本 #!/usr/bin/python # -*- coding: utf-8 -*- import Adafruit_BMP.BMP085 as BMP085 #import cgi sensor = BMP085.BMP085() temperature=sensor.read_temperature() pressure=sensor.read_pressure() pressure=pressure/100.0 print

我想在html网页上显示到值。我有一个Python CGI脚本

#!/usr/bin/python
# -*- coding: utf-8 -*-

import Adafruit_BMP.BMP085 as BMP085
#import cgi
sensor = BMP085.BMP085()

temperature=sensor.read_temperature()
pressure=sensor.read_pressure()
pressure=pressure/100.0

print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<body>'
print "%.2f °C" %temperature
print "%.2f hPa" %pressure
print '</body>'
print '</html>'
#/usr/bin/python
#-*-编码:utf-8-*-
将Adafruit_BMP.BMP085导入为BMP085
#导入cgi
传感器=BMP085.BMP085()
温度=传感器。读取温度()
压力=传感器。读取压力()
压力=压力/100.0
打印“内容类型:text/html\r\n\r\n”
打印“
打印“
打印“%.2f°C%”温度
打印“%.2f hPa%”压力
打印“
打印“
当我从控制台调用它时,它工作正常,但是当我通过iframe包含它时

只有一页白纸。该文件是可执行的,Web服务器支持CGI。谢谢您的帮助。

如果您在浏览器中打开
daten.py
,是否有效?i、 e.
http://yourdevice/daten.py
?html文件和daten.py都在同一个文件夹中吗?不,它不工作。我只得到一页空白。这两个文件位于同一文件夹中。那么恐怕您的服务器设置不正确:/服务器日志中有错误吗?