Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

combining html front-end and python "back-end" in mobile app

My application has an html-based front-end and uses python logic on the back-end. This application needs to run offline, not connected to the internet, so by "back-end" here I don't mean a server running remotely, but rather python logic running side-by-side in the same app as the browser/html engine. For Windows or Mac desktop apps, I build a Chromium Embedded Framework application, and then launch a sub-process which runs a CherryPy python application built using py2exe (or py2app). The client and the server then communicate using normal http.

I'd like to achieve the same thing on both iOS and Android. I've researched several alternatives, but nothing seems to do quite what I need.

Kivy is close, but as far as I can tell it doesn't offer a browser/html front-end, but rather provides its own layout engine on top of OpenGL. It has an extension mechanism, but that seems to be more about extending the python side, not the front-end side.

On the other hand, I could start with PhoneGap and then add a python library as an extension (possibly using Kivy's mobile library build of python). Or for that matter I could just write a regular C++ app that embeds a browser and uses a python library build.

On the third hand, I've played with using various python-to-javascript converters to get the back-end logic into something that can work with PhoneGap directly, but that approach gets pretty difficult given all of the python logic I have -- some of it just doesn't convert so easily.

Do you know of apps that are displaying html and running python logic in the same app?

like image 679
M Katz Avatar asked Oct 22 '22 00:10

M Katz


1 Answers

You could do a very simple kivy app, that would start a service (inside which you would do your "server" side, with a small engine like flask or bottle, but i guess cherryPy should work too), and in the main.py of the "kivy" app, don't import kivy, just import webbrowser and start a browser window to localhost:your port. This will use the android browser.

edit: oh, services are android only for now, apparently ios 7 supports them too, but kivy-ios hasn't been updated to make use of them.

like image 184
Tshirtman Avatar answered Oct 27 '22 09:10

Tshirtman