The following steps can be used to run the raspberry-pi-server
without using a container (Docker, Kubernetes, etc.).
NOTE: Alternatively you can run the following command from your Raspberry Pi to perform these steps for you:
sudo curl -fL https://github.com/rustygreen/raspberry-pi-server/blob/main/scripts/setup.sh | sh -
Review the setup.sh script before executing (don't just trust me).
- Install Git on your Raspberry Pi
$ sudo apt update
$ sudo apt install git
$ sudo apt update
$ sudo apt install python3 idle3 pip3
- Clone the repository
$ cd /home/pi # Or wherever you want to store your code.
$ git clone https://github.com/rustygreen/raspberry-pi-server.git
- Install Python dependencies
$ cd raspberry-pi-server
$ pip3 install -r requirements.txt
- Run Server
$ sudo python3 server.py
- Consume the services
Returns a list of pins and their state (1 or 0)
$ curl http://localhost:8080/pins
Returns the state for GPIO pin #7
$ curl http://localhost:8080/pins/7
Sets the state of GPIO pin #7 to 1 (high)
$ curl http://localhost:8080/pins/7/1
You should get back a JSON list of the GPIO pins and their current state.