'Threaded python server returns empty response on Raspberry Pi but works locally
I'm working on creating a dashboard for sensors attached to a Raspberry Pi Zero W, which automatically launches in a browser on boot.
The backend is Python, the frontend is a single HTML page with some JavaScript & jQuery, and it all worked great.
Check out server.py in repository
Problem: The main thread is now blocked, because some sensor readings require listening for GPIO interrupts, so I had to move the server to its own thread.
This still works locally, but on the Pi the AJAX POST calls to the server return an empty response (the web page still loads correctly though, so the server is definitely running).
The only difference between the two systems is which browser is being used (Chrome locally, chromium-browser on the Pi):
def _open_browser():
if is_raspberrypi == True:
os.system('chromium-browser --noerrdialogs --disable-infobars --check-for-update-interval=31536000 --kiosk "http://localhost:%s/" & ' % (PORT))
else:
webbrowser.open('http://localhost:%s/' % (PORT))
thread = threading.Timer(0.5, _open_browser)
thread.start()
Any idea how I can get the server to return a response like it does on my local machine?
Thanks so much!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
