I had a pi-copter project. My idea to control it is using web page. I have done it using php. But the copter running gyro sensor to makes it stable while flying. So, to run and get data from the sensor, it have to be programmed. I using python to run the sensor. the script will process a control to esc from orientation and from data that I sends using front-end web page.
my question is how python listens GET data from front-end web page?
Related
I'm trying to build my own remote desktop which can be accessed by the browser. My first idea was building a server (with python I would use flask) and including the graphical output of the OS into my html page. Because I thought that that would be difficult/not possible my next plan is to get just the graphical output of one program which I started from the server.
Please tell me how I could do this or how I could start with this project.
This is a daunting task, but I guess this procedure would be a good start for a prototype.
Capture the display using ffmpeg:
Capturing and streaming with ffmpeg while displaying locally
Create a route to view this stream: Streaming MOVIE Python flask
Listen to click/keyboard events on the page and relay them back to source, apply these interactions using a input driver
I've written an algorithm in python and a web interface around that. After you submit the form and start the algorithm, I'd like to push and update data on the page as it's running. How can I accomplish this?
To have real-time or semi-real time communications between the web page the options are
Automatically refresh the page after certain seconds using meta refresh tag in HTML <head>
Fetch updated data with JavaScript and AJAX HTTP GET: https://api.jquery.com/jquery.get/
Use server-sent sent events: http://www.html5rocks.com/en/tutorials/eventsource/basics/
Use WebSockets: http://www.html5rocks.com/en/tutorials/websockets/basics/
All approaches, excluding the first one, require rudimentary JavaScript skills besides knowing server-side Python. The latter two approaches recommend advanced understanding of real-time communications. Thus, if you are not familiar with the web development I recommend picking the meta refresh tag.
On the server side you need to start a process or a thread which to handle the long running process, then have this process to write its progress to a database. When the web UI updates itself, it reads the latest results from the database and pushes/pulles them back to the browser.
I am working on a project, where I want to be able to retrieve real-time updates if users upload a picture on Instagram with a specific tag (a custom action should be executed when a user uploads a picture with a specific tag). The whole thing should be written in Python and should be running on a stand-alone Raspberry Pi.
As far as I have understood the Python Instagram API sends a GET request to the specified callback url which needs to respond with the hub.challenge parameter and so on. This means that the Python Script needs to run on the Server that is also hosting the callback url right? Which would mean that I can not do this on a Raspberry Pi.
Am I missing something here? I also built a similar thing with the Twitter Streaming API and it was not a problem at all!
Thanks in advance!
If you successfully used twitter on raspberry (I did it also, with Twython, which was fun), you can just use ifttt to send a tweet automatically each time there's a new photo on instagram. With the raspberry, you can check for new tweets regularly.
I have the following problem:
The big picture: steering a stepper motor via broswer. The stepper motor is connected to a Fox Board with debian. On the board an apache webserver is running.
I have a HTML website with a form, in which the user enters the parameters for the motor. The submit button starts a python script, which does the communication with the motor. The motor delivers some data to the python script. The script sends this information back to the HTML page in an iframe.
web page with form -->
parameters input by user -->
submit -->
python script is started -->
motor does something -->
motor sends answer to python script -->
answer is submited by python to web page in iframe.
Works...
One value that is returned by the motor is important, if it exists, I would like to have it in my form in the web page. Not only displayed in an iframe.
My question is:
a) Is this possible in principle?
b) if yes, how can it be done? Meaning, which are key words to search for? (No clue right now)
c) Is there an alternative.
To a: A self invoking php script could be a solution. But how can I program such a script, that while pushing a submit button, the php is self invoking, the python script gets started, the php waits until python delivers feedbach and finally, the php builds up itself with the data recieved.
I'm on the edge of my own incompetence...
I appreciate any help, suggestions etc... Please just send me in the right direction, Peter
You could do it with AJAX (asynchronous javascript) and python web services, in general.
The communication would be handled on the client with javascript, and it would invoke your python script (the web service), which would do the work with the motor, and then send the response back to the web page, which would be able to show new readings/state (again, through javascript).
I have written a program using Python and OpenCV where I perform operations on a video stream in run time. It works fine. Now if I want to publish it on a website where someone can see this using their browser and webcam, how do I proceed?
not really sure what you want to happen but if your going to implement this kind of feature in a website I think you should use a flash application instead of python (or if possible html 5). though your using python on the development of you web app it would only run on the server side instead and the feature you want to use is on a client side so for me it's more feasible to use flash instead to capture the video then after capturing the video you upload it to your server then your python code will do the rest of the process on the server side.