This project will use flask to return the sensors data to "http://your-ip/node-01" as a web service in JSON type.
- Linux OS
- Python 3
- flask, RPI.GPIO, board, serial, adafruit-blinka, unzip
- Download and install Python 3 on Official Website
- Download the project to /home/pi/ and unzip the project
$ cd /home/pi
$ sudo apt-get install unzip
$ wget https://github.com/yimincai/IOT-Web-Service-on-Raspberry-Pi-4/archive/master.zip
$ unzip IOT-Web-Service-on-Raspberry-Pi-4-master.zip
- Install require libs:
$ pip install flask RPi.GPIO board serial
$ pip3 install adafruit-blinka
- Download the project to /home/pi
- add this line to
/ect/profile
to let project auto run on boot
$ sudo python3 /home/pi/Sensors/app.py &
- Change python files permission
$ sudo chmod 777 /home/pi/Sensors/app.py
$ sudo chmod 777 /home/pi/Sensors/sensors.py
- Reboot your Raspberry Pi 4 to test the service
$ sudo reboot