Python Forum
How to send data from remotely hosted HTML form to Pi
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.
Reply
#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
Reply
#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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python packaging/ hosted in IIS server manjureka 0 112 Apr-16-2024, 10:43 AM
Last Post: manjureka
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 843 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  Post HTML Form Data to API Endpoints Dexty 0 1,399 Nov-11-2021, 10:51 PM
Last Post: Dexty
Question Flask, Self-hosted deployment, which server ? SpongeB0B 1 3,023 Apr-11-2021, 11:29 AM
Last Post: snippsat
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,619 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Cleaning HTML data using Jupyter Notebook jacob1986 7 4,127 Mar-05-2021, 10:44 PM
Last Post: snippsat
  Using Python request without selenium on html form with javascript onclick submit but eraosa 0 3,170 Jan-09-2021, 06:08 PM
Last Post: eraosa
  Any way to remove HTML tags from scraped data? (I want text only) SeBz2020uk 1 3,459 Nov-02-2020, 08:12 PM
Last Post: Larz60+
  Django send email - email form Remek953 2 2,294 Sep-18-2020, 07:07 AM
Last Post: Remek953
  How to send notifications to gmail from contact form using Django and pushbullet Justchse 0 1,866 Sep-01-2020, 01:19 PM
Last Post: Justchse

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020