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?
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.
Related
I am currently working on an app for android devices. However, the application is too big to build for the device. Therefore, i want to build the core of the application (the part that does most of the work) and place it on a server, and build the light weight part of the application for the mobile device. The App on the android device is to connect to the application on the server, and collect the processed information. I want to build the application that is to run on a server with the Python language, as the application I'm working on does a lot of numeric crunching. Is this possible? If so, how can i embed my Python script to a web server and how to link it to my application
On the server side I would suggest looking the Flask framework (you may find the Flask-Restful framework and having the mobile app accessing it via a REST API. This may be useful depending on your Android experience: http://developer.android.com/training/volley/simple.html However, if you are doing a lot of number crunching, you may need to use WebSockets to connect the two and run your processing in a background thread. In which case I would look at http://www.elabs.se/blog/66-using-websockets-in-native-ios-and-android-apps and https://flask-socketio.readthedocs.org/
We have just reached some sort of a brick wall in our project and would
appreciate some comments or suggestions or pointers, anything at all.
Problem Statement
Making a web-technologies (html5/canvas) based mobile/tablet app that can
do some natural language processing.
Our Constraints
For UI, we are more reliant on prototyping it with html5 technologies
like the Canvas api, SVG. It aligns a lot with our skills and has the
requisite capabilities
NLP libraries are more mature and well developed in Python (like NLTK)
Some alternatives that we tried
Javascript based libraries for NLP. They might not be as matured, but
could have proved a faster alternative if there were JS libraries for NLP.
We found these:
Natural https://github.com/NaturalNode/natural
Other JS based libraries:
http://www.chrisumbel.com/article/node_js_natural_language_nlp
But they proved to be Node based and we couldn't figure out a way
to add them to a browser kind of page, so that we could embed it into a
"PhoneGap" type platform. We could be wrong.
To use Python NLP logic in our mobile app, we tried some cross
platform libraries:
PhoneGap http://phonegap.com/
This StackOverflow
responsePhoneGap with Django Backend
suggests
that "you cannot run python code on iOS or Android using PhoneGap"
Qt 5 http://qt-project.org/,
Qt5-mobilehttp://qt.digia.com/qtmobile/
There 2 promising Python Based Qt libraries:
PyQthttp://www.riverbankcomputing.com/software/pyqt/introand
PySide http://qt-project.org/wiki/PySide
This QML/Python/Qt
demohttp://qt-project.org/wiki/Using-QtWebKit-and-QML-with-PySideis
almost exactly what we want:
There is a Python backend with JS calling python objects and
vice versa using methods like: sendData(), receiveJSON() ...
But it doesn't seem to compile on our machines, and later we
found PySide development has stagnated and supports only
till Qt4.8,
whereas Qt5+ provides support for mobile/tablet development.
This blogpost details how some app developers used Python for
backend and QML for
UIhttp://blog.qt.digia.com/blog/2012/03/23/mixd-tv-leveraging-qt-quick-for-a-rich-desktop-ui-from-a-python-back-end/.
But its just descriptive, and doesn't give real information.
Kivi http://kivy.org/docs/guide/packaging-ios.html#:
Despite some niggles, it does seem to work but it doesn't seem
to have a way to develop a 'UIWebView' class based iOS app,
which we need
to use our html5 based UI.
Pythonista http://omz-software.com/pythonista/:
Same problem as Kivi above. We don't want to develop the mobile
app using Python, we just need a python backend for our html5
based webapp
iOS: We checked the native iOS development libraries also, but
couldn't find an easy way to embed a python backend logic
Android: ? Does anyone know if we could embed python into an
web-based app.
AJAX calls to Flask server:
This is the last option, that we are fairly confident about. Host
python logic on a Flask server and make AJAX calls from the webapp. But
given its for an application for kids, we might end up making
numerous AJAX
calls for same part-of-speech tagging
Any help/suggestions are most welcome.
I have a small android application made in eclipse.
Now i need to build a web server with python so they could work together.
Should i make a new python projekt then in some way link it to my application?
Or
Should i use jython and rebuild the app in a jython project?
I have used Visual studio before, and eclipse is not my hometown, så i would really appreciate clear answers.
You don't seem to have a clue about how the android app and the web app are supposed to work together...
You can (theoretically) use just any language and techno you find appropriate for the web app since the communication between the android app and the web app will be http requests / responses.
Also, you can use whatever code editor you want to write Python code, as long as it (the code editor) supports Python.
You can use Kivy to write Python apps that work on Android (as well as just about any other system). Python, they say, has a built in module that you can easily make a web server with. I'm about to try it, I believe.
See
* kivy.org
* http://m.linuxjournal.com/content/tech-tip-really-simple-http-server-python
As an alternative to having to create an “external” in c/c++/objc to a new Livecode application, I have developed instead a Python network socket app that communicates with it via sockets. The reason for this is that I needed to use some functions provided by some of my “custom” Python libraries. These functions are not doable in Livecode natively at this time. The communication between the Livecode and the Python apps works just as I desire.
I have only tested this technique in a desktop app on OSX for now. When saving the standalone, I’ve bundled my compiled Python app in the “Standalone LC Application Settings” and the whole thing installs and works without problems.
Now, can the same task possibly be accomplished for IOS and/or Android apps?
Can I bundle a compiled Python script with a Livecode IOS/Android mobile app in order to run in these devices? I’m aware of course, that Python is not installed by default in either IOS or Android. What is the best way to accomplish this then? I’m pretty new to Livecode. I’ve tested my Python script on Pythonista on both an iPhone and an iPad just to make sure it will run and it works flawlessly there. So, how do I package my Livecode app with my python script so they could be both installed and ran in the mobile devices?
How do you call your Python scripts? The Shell command is not available on mobile so I guess you would need to create an external that would call your compiled script. But then sockets isn't available either on mobile yet (will soon be afaik). But out of curiosity what is your python script doing that can't be done in LiveCode?
I have a regular web based application written using JSP, HTML, Javascript. Can I use some of the mobile development platforms to deploy it as a native app on either Apples's iOS iPhone or on Android platform?
The idea is to "develop once and run everywhere" - meaning, be able to deploy the same application on multiple platforms such as Web based application, iOS based app and Android based app.
While this would be great, I am unsure if this can be done. I understand that this may be accomplished if the front end part is written in HTML5, CSS3 and Javascript. However, it would be very cumbersome to write the application front-end only using these technologies without either Java or ASP .Net.
To a point: no.
Precisely, you might be able to get a servlet container running on an Android device, but you almost certainly won't be able to pull it off on an iOS device.
Actually writing a front-end application without using server side technologies isn't that difficult with JavaScript and HTML5. Rewriting an existing application is certainly a complex project though.
The currently popular "develop once, run anywhere" platforms for mobile devices are Apache Callout (previously PhoneGap) and Appcelerator Titanium.
Callout is based on making a thin Webkit shell as a native application, and then injecting interfaces towards the phone's features into the JavaScript context of that Webkit instance. It's easier to get into than Titanium, and it is completely free.
Titanium is also JavaScript based, but partially compiles your JavaScript code into native code which is then compiled by your native development stack for each platform. The upside is somewhat more responsive program. Some features require buying a license.
Having tested both during the last two weeks, I believe that depending on such solutions at this time amounts to technological suicide. Both of these systems are slow, buggy and even require licensing. Users will recognize apps made with them and generally reward you with poor ratings and reviews on markets.