Saturday, September 23, 2023

Looking to go from zero to api as first project.


full image - Repost: Looking to go from zero to api as first project. (from Reddit.com, Looking to go from zero to api as first project.)
Hello,So I have a raspberry pi running flask behind my firewall on my private network that I can vpn into.I have a python script to toggle gpio pins..which (via relay) toggle mains power outlets.I'd like to get these to toggle via a simple website rather than having to ssh into the pi and run a script..The script has to continue running to keep an outlet on. So I run inside tmux. If the script stops, the pi defaults to turning the gpio pins off. So I'd like to have it running inside flask and call functions into it to toggle.Eventually, I'd like to have a phone app (android) to do it without a browser...but thats way down the line.I've tried reading various beginner flask tutorials, but they all focus on templates and css, etc. to build a fake social media site. Im perfectly ok with generic html look and feel. I just want 2 lines:Outlet 1: {On/off} [Toggle]Outlet2: {On/off} [Toggle]​So I think I need it be up and running independent of any page I might be on. Does that mean I should write out all the code and funtions in the routes.py file above the index declaration? Write it out as a seperate file and import it, then instantiate it?Thanks.


Mining:
Bitcoin, Cryptotab browser - Pi Network cloud PHONE MINING
Fone, cloud PHONE MINING cod. dhvd1dkx - Mintme, PC PHONE MINING


Exchanges:
Coinbase.com - Stex.com - Probit.com


Donations:
Done crypto



Comments System

Disqus Shortname

Disqus Shortname

designcart
Powered by Blogger.