GPIO引脚状态是否将其存储在字典或数据库中?

时间:2019-02-25 18:31:42

标签: flask flask-sqlalchemy

大家好在我的项目中,我使用raspberrypi的GPIO,需要存储每个引脚的状态,然后在更改时更新记录。我遵循的教程使用python字典tutorial

`def main():
   # For each pin, read the pin state and store it in the pin dictionary
   for pin in pins:
      pins[pin]['state'] = GPIO.input(pin)
      'pins' : pins
      }
  return render_template('main.html', **templateData)`

这很好用,但是我正在使用16个针脚,每个针脚的目的都不相同,我想知道由于该页面对多个用户可见,所以最好将其存储在数据库中,我正在使用SQLAlchemy,我想保留字典在其自己的文件(pins.py)中,以便我可以将其导入为不同的视图。 提前致谢 保罗

0 个答案:

没有答案