I am building a flask application to control GPIO on my raspberry pi. I am using the larger application Flask structure because even though my app isn't huge I very much enjoy having everything in separate files.
One thing I am not sure about is how to go about importing RPi.GPIO so that circular/redundant imports don't occur. In this tutorial GPIO is imported into what would be the views.py
in my file structure. But the author also uses GPIO inside the if __name__ == "__main__"
block for initialization code.
Where would the if __name__ == "__main__"
initilization code go for my file structure? I was thinking putting it in run.py
right before app.run(debug=True)
but I am not sure if this is where it is typically placed.
Secondly, If I import GPIO into the place where my initialization code goes will I run into circular/redundant import problems if I also import it in views?