Combining html front-end and python "back-end" in a mobile application

My application has an html-based interface and uses python logic on the internal server. This application should work autonomously, and not connected to the Internet, so by β€œback-end” here I do not mean a server that works remotely, but rather python logic that works side by side in the same application as the browser / html engine . For Windows or Mac desktop applications, I create a Chromium Embedded Framework application and then run a subprocess that runs the python CherryPy application built using py2exe (or py2app). Then the client and server exchange data using regular http.

I would like to achieve the same as on iOS and Android. I have explored several alternatives, but nothing seems to do what I need.

Kivy is close, but as far as I can tell, it does not offer a browser / html interface, but provides its own build mechanism on top of OpenGL. It has an extension mechanism, but it seems to be more about extending the python side, rather than the interface side.

On the other hand, I could start with PhoneGap and then add the python library as an extension (possibly using the KIVI-mobile python library assembly). Or, for that matter, I could just write regular C ++ - an application that embeds a browser and uses the python library assembly.

On the third hand, I played using various python-to-javascript converters to get the internal logic into something that can work with PhoneGap directly, but this approach becomes quite complicated considering all the python logic I have - some of them just don't Convert so easily.

Do you know about applications that display html and run python logic in one application?

+4
source share
1 answer

You can make a very simple kivy application that will launch the service (inside which you will make your "server" side, with a small engine, for example, a jar or a bottle, but I think cherryPy should work too), and in main.py kivy applications, do not import kivy, just import the webbrowser and launch a browser window on localhost: your port. This will use the Android browser.

edit: oh, android services only at the moment, apparently ios 7 supports them too, but kivy-ios is not updated to use them.

+2
source

Source: https://habr.com/ru/post/1502926/


All Articles