I have created an extention to my network using RaspberryPi 4 and also wanted to check the status of pi so I have made this python api. It is more like a cheat sheet for me for some later uses or when i forgot something.
How i made my WiFi signal recived by Pi to be shared by LAN:
- Install dnsmasq
sudo apt-get install dnsmasq
- Open /etc/dhcpcd.conf
sudo nano /etc/dhcpcd.conf
- Add two lines at the bottom and save
interface eth0
static ip_address=192.168.4.1/24
- Make a backup of orginal dnsmasq.conf
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
- Open /etc/dnsmasq.conf
sudo nano /etc/dnsmasq.conf
- Add two lines and save
interface=eth0
dhcp-range=192.168.4.8,192.168.4.250,255.255.255.0,12h
- Open /etc/sysctl.conf
sudo nano /etc/sysctl.conf
- Uncomment or add this line inside a file
net.ipv4.ip_forward=1
- Open /etc/rc.local
sudo nano /etc/rc.local
- Add this line above just above
exit 0
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
- Reboot the Pi
- Creating a virtual enviroment named
rest
using python
python3 -m venv rest
- Activating virtual enviroment
#Pi version
source rest/bin/activate
#Windows testing version
rest\Scripts\activate
- Installing needed dependency using pip
#Installing
pip install -r requirements.txt
#Exporting fixed version
pip freeze > requirements.txt
- Exporting flash app and running it
#On Windows use set instead of export
export FLASK_APP=main.py
flask run --host=0.0.0.0