Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to send data from remotely hosted HTML form to Pi
#1
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.
Quote
#2
(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
Quote
#3
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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  got some problem with flask signup form. darktitan 0 27 7 hours ago
Last Post: darktitan
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 2 84 Yesterday, 11:24 AM
Last Post: snippsat
  HTML Styling Not Working yoitspython 1 119 Aug-13-2019, 06:26 AM
Last Post: fishhook
  spliting html code with br tag yokaso 11 370 Aug-07-2019, 03:18 PM
Last Post: snippsat
  How do I get rid of the HTML tags in my output? glittergirl 1 433 Aug-05-2019, 08:30 PM
Last Post: snippsat
  convert html table to json bhojendra 5 177 Jul-30-2019, 07:53 PM
Last Post: DeaD_EyE
  How to capture Single Column from Web Html Table? ahmedwaqas92 5 300 Jul-29-2019, 02:17 AM
Last Post: ahmedwaqas92
  Getting a specific text inside an html with soup mathieugrimbert 9 394 Jul-10-2019, 12:40 PM
Last Post: mathieugrimbert
  getting options from a html form pgoosen 5 352 Jul-03-2019, 06:07 PM
Last Post: nilamo
  form.populate_obj problem "object has no attribute translate" pascale 0 183 Jun-12-2019, 07:30 PM
Last Post: pascale

Forum Jump:


Users browsing this thread: 1 Guest(s)