douhui8454 2015-09-21 13:05
浏览 1409

将python输出值传递给HTML网页

I am working on a audio sensor which detect the frequency or db if you called it. Now that my python program is able to detect the 'db', but I want to use the output and sent it to my web page HTML.

I am using raspberry pi to do that, and also my web server is being hosted by the raspberry pi as well. So basically, the raspberry pi does 2 things, Host webpage & detect the frequency level.

I do not have any idea how to pass those value to HTML.

The follow code is my Python code that I got from online:

import RPi.GPIO as GPIO, time, os
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

def RCtime(Pipin):
    measurement = 0
    GPIO.setup(Pipin, GPIO.OUT)
    GPIO.output(Pipin, GPIO.LOW)
    time.sleep(0.1)
    GPIO.setup(Pipin, GPIO.IN)
    while(GPIO.input(Pipin) == GPIO.HIGH):
         measurement = measurement + 1
         frequency = (measurement *3.3)/1024
    return frequency

while True:
     frequency = RCtime(18)
     print 'The frequency reading is ', frequency
     time.sleep(0.2)

From my knowledge, I am making a guess that I maybe able to use the output value from the following statment to pass it to my HTML webpage.
print 'The frequency reading is ', frequency

  • 写回答

1条回答 默认 最新

  • dslk6326846 2015-09-21 13:22
    关注

    You have to store your 'db' value into a database (sqlite for example) and then make your webpage read it.

    评论

报告相同问题?

悬赏问题

  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题