I am a hobbyist and have learnt most of what i know about coding by trawling these forums.
I have a network of Raspberry Pi computers that are programmed to take a photo when the server sends a multicast message. this is all working and implemented in Python.
I would like to setup a webpage to act as a GUI to send the multicast message including some parameters which are passed to the python script when it is executed. I would be happy for a button which launched the script and go from there.
I have setup apache and have been able to launch php and python simple scripts directly.
The scripts that i have created so far are only 'hello world' style scripts, anything more than printing to html seems to fail without any feedback So far i have been searching for a few weeks, i have done tutorials for HTML CSS Javascript and Jquery and am no closer. I have also considered running the whole thing from a python web framework but didnt have much luck with that either. Ideally, i would like to have a webpage that can run a script when the buttons are pressed.
I understand that this is probably too many words with out any code but i am quite lost at the moment. It seems like a task that i should be able to find tutorials for but i have had no luck. Any help would be appreciated.
-
2Could you please structure your question by adding some paragraphs? It is very hard to read and understand.user1907906– user19079062015年01月29日 12:00:16 +00:00Commented Jan 29, 2015 at 12:00
-
stackoverflow.com/questions/19331969/… : Another rapsberry user did something similarnicolallias– nicolallias2015年01月29日 12:18:42 +00:00Commented Jan 29, 2015 at 12:18
-
Thanks for your help but how do I do that without. Navigating away from the page?Joe Jordans– Joe Jordans2015年01月30日 20:20:06 +00:00Commented Jan 30, 2015 at 20:20
1 Answer 1
A web framework is the best way to approach this. Take a look at flask. It's a very lightweight and has good tutorials.
Start by installing flask. Id recommend installing in a virtual env.
Then create an app something like this:
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index():
return '''
<html>
<a class="btn" href="/takephoto">Take Photo</a>
</html>
'''
@app.route('/takephoto')
def take_photo():
# Run code or function for taking photo here
return 'Photo Taken'
if __name__ == "__main__":
app.run()
Comments
Explore related questions
See similar questions with these tags.