How to send data from remotely hosted HTML form to Pi - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: How to send data from remotely hosted HTML form to Pi (/thread-19237.html) |
How to send data from remotely hosted HTML form to Pi - sajid - Jun-19-2019 I'm working on a small project to turn home lights On & Off using Raspberry Pi. I'm able to do so using Python . Now I want to make a web interface to control things. This is the interface I made initially: https://sajidjunoon.github.io/IoT_Project I wanted to know how will I send data from remotely hosted app/HTML button to my RaspberryPi. What language/library will be used here and how it will be implemented? I'm sorry if this question is not meant to be posted to this forum. RE: How to send data from remotely hosted HTML form to Pi - snippsat - Jun-20-2019 (Jun-19-2019, 07:09 PM)sajid Wrote: I wanted to know how will I send data from remotely hosted app/HTML button to my RaspberryPi. What language/library will be used here and how it will be implemented?You can still use Python eg Flask is fine for this. So from your html code vaule get send to server Flask. On server can send to eg PI LAN http://adresse.lan/light_on Minimal running example. from flask import Flask, request app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': light = request.form.getlist('light')[0] if light == 'on': print('Light on') # http://adresse.lan/light_on if light == 'off': print('Light off') # http://adresse.lan/light_off return '''\ <form method="post"> <input type="checkbox" name="light" value="on" checked> <input type="checkbox" name="light" value="off" checked> <input type="submit"> </form>''' app.run(debug=True)For host recommendation look this post RE: How to send data from remotely hosted HTML form to Pi - sajid - Jun-27-2019 Thank you for your reply. I got the solution which I was looking for. It's AWS IoT, I'm doing this using AWS IoT SDK where communication will happen over MQTT in JSON format. |