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.

    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划