I'm making a web interface for my Raspberry Pi using Django.
I'm trying to execute python code which lights up a display by simply clicking a HTML button inside a Django Template.
I currently light up the LED display by running this on command line:
cd rpi/
sudo python bubbles.py
Which executes that ^ python code However I might want like to change the .py file depending on the HTML ID:
sudo python file_name.py
Anyways, this script needs to be executed via web browser so I wrote a view ...but I have no idea how to link a script to a view. My template:
graphics_list.html
{% extends "base.html" %}
{% block content %}
<h1>{{ title }}</h1>
<h1> Scrolling Raspberry Pi LED Selection </h1>
{% for obj in object_list %}
<h3><a href='{{ obj.get_absolute_url }}'>{{ obj.name }}</a></h3>
<img src="{{ obj.image.url }}" alt="..." class = "img-responsive"><br>
<p><a href="{{ need_to_execute_script_somehow }}" class="btn btn-primary" id = "{{ obj.name }}" role= "button">Use</a></p>
{% endfor %}
{% endblock content %}
I really don't know where to begin, should I use AJAX for this, PHP?