Innyve89
Posts: 9
Joined: Wed Jan 10, 2018 12:35 pm

How to control a python script over a local web server?

Fri Mar 30, 2018 4:00 am

The goal of my project is to make a robot that is wirelessly controlled. I can be controlled via a gamepad controller locally when connected to the raspberry pi (the raspberry pi is connected to a pwm board to which motors are connected). This is done in one python script and can do stuff for each button. I'm running lighttpd on the pi as a website host for the audio and visual components. Currently I've tried to use html 5 to recognize the controller and run a script for each button. This is proving to be complicated (around two scripts per button), and not working correctly. It seems that lighttpd can only really run one script at a time. I hold a button to turn on light A (works), keep holding that button hold another to turn on light B (works) - I let go of button A and B also shuts off. I was wondering if there is a way to pass through the usb device to the python script located on the pi. Somehow use just one script that tells it that usb device is not local but on a client. Any help is appreciated thank ya!

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: How to control a python script over a local web server?

Fri Mar 30, 2018 8:35 am

Ditch lighttpd and try this instead.

https://github.com/dddomodossola/remi

I would seperate my code into two scripts: one for keyboard-only and one for web-only
control. Unless you already know how to combine them into one (probably quite possible in general).

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Innyve89
Posts: 9
Joined: Wed Jan 10, 2018 12:35 pm

Re: How to control a python script over a local web server?

Sun Apr 01, 2018 4:08 am

I really need it to work it lighttpd though, is there any way to simply have the usb device's event go straight through the browser to the server?

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: How to control a python script over a local web server?

Sun Apr 01, 2018 8:01 am

Make the two scripts communicate with each other via ZeroMQ ? Seems to be the simplest solution.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “Troubleshooting”