Remote Control with BaseHTTPServer
I've been doing some brainstorming on something...
(sorry this is about something in Editorial but more so about the ability of Python code so I put it in the Pythonista forum)
I have a presentation script that I use for teaching. Currently it's an implementation of remarks.js within python. So I'm able to do a presentation using a markdown file and I use this in Editorial. It's brilliant and much easier to use than silly silly powerpoint etc.
The other day Apple updated their iWorks suite with multitasking. I played with it a bit - and now you can use Keynote remote on splitscreen while displaying something (like notes) and on iphone you have the presentation running. That's awesome.
really hoping for multitasking support in editorial :)
So I was thinking if I can do that in Editorial/Pythonista with my presentation script.
I did a bit of looking around and saw that we have BaseHTTPServer installed already. Before I bother writing a bit of code, I'm wondering if anyone has any experience with this and can offer some insight.
I'm wondering if I can pull this off:
on one iDevice:
- Run my presentation script (which is a UI webview) on my iPhone
- In the background it runs an HTTPserver which serves a simple webpage with some buttons (next, previous etc.)
- the server then can take POST requests and handle them to do things (next, previous etc)
on the other iDevice:
- connect to the server and show the simple webpage (I could easily create this to be a simple UI split screen (notes+control).
Do you think this is all possible?
Not commenting on your idea itself but I've noticed when I've worked with *HTTPServer it tends to quit running after a while.
I don't have useful diagnostics but if it's unreliable then you have to be aware it might not be up when you try to use it.
(And my application is to use Safari in Slide Over mode, served by Pythonista - so not too dissimilar to what you're doing.)
Do you think that has to do with backgrounding?
Cethric last edited by
I have not done any research into this however if it is the result of background tasks try using this.
Also something to think about is the presentation on both devices does not necessarily need to be a *HTTPServer but could simply be ui.WebView.load_html('filename.ext') calls and then a simple Socket server between the two devices to call 'page' changes
ccc last edited by ccc
Overall, I would say that your idea should be doable. You might check out the last post in this thread.... https://forum.omz-software.com/topic/532/feature-request/6 I tried with HTTPServer but shifted to Bottle (or your could try Flask) instead because I found it to be more robust for this purpose than HTTPServer.
@ccc So I've typed in the bottle "Hello World" example and I'll see how resilient it is.
Okay thanks everyone! Sometime I'll look into it a bunch more. Appreciate the alternate suggestions @ccc