Python + Django on Android - android

I am a Django developer and wanted to know if anyone has any idea of the possibilities of installing and developing on Django using an Android tablet such as the nexus 7. This seems like a reasonably powerful device, can be hooked up with a bluetooth keyboard, and has linux at the core of the OS.
So - is it possible to install Python and Django (or even Flask) on Android?

Yeah! its posible!, but you need install termux terminal on Android and later open the termux terminal and write:
apt-update
apt-install python
pip install django
django-admin startproject demo
cd demo
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser, see the picture:

We're developing PythonAnywhere to fill just this kind of niche. We tuned it to work with the iPad first. But it seems that the Nexus 7 is popular enough now that there might be enough demand to do the same thing for Android.

SL4A is a ridiculously excellent library/sdk/app for android and gives you a way to install a number of language/scripting runtimes and a thin veneer for accessing android functionality via the scripting frameworks.
It so happens that Python is an option, and I've used it with cherrypy (python framework) on Android. I haven't tried it with flask or Django but with some work it should be possible.
The app provides a way to download python, install it, and then a way to launch a python console or even just run python scripts.
http://code.google.com/p/android-scripting/
There was a downside to the python support originally, due to a silly bug/limitation in the Android SDK. This restricted the use of apk assets with _ underscore in the name. The details are faint in my mind, but I am subscribed to the issue in Android so I can follow up with the details about this issue. This would present a problem with many of the python frameworks, as underscores are part of python style.

One good way to accomplish a django development environment on a Nexus7 is to install a linux distro with a package manager alongside Android. Debian Kit hooks into the existing Android directories with symlinks instead of a chroot environment.
With that you can install Debian or Ubuntu and use apt-get and pip to install git, virtualenv, and all the packages and libraries you need to set up your development environment as you would on a desktop. You can write your code in DroidEdit, run the django development server in an Android terminal through ssh to localhost, and test your app right there in the browser on Android.

I could run on my Tablet (android) and smartphone (android) following the procedure below:
Install "GNUroot Debian" app;
Open "GNUroot Debian" app;
Run these commands:
apt-get update
apt-get install python3
apt-get install python3-setuptools
easy_install3 pip
pip install django
django-admin startproject demo
cd demo
python manage.py runserver

QPython suports Django on Android. I am running it on my android device.

Do you want this? :
p.s: I confess that article's original source is me. But isn't it nice? :)

Well if your end goal is to develop Web applications and host host them on your Android and since you had flask there why not give bottle.py a shot. It's just one file that you copy into your sl4a scripts folder and voila. Bottle is minimalist and near similar to flask. No rooting or Unix environments required.

Install termux terminal on Android and later open the termux terminal and write:
pkg install python
pip install django
django-admin startproject demo
vim demo/demo/settings.py
In settings.py
ALLOWED_HOSTS = ['*']
After save the settings.py and
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser

If you are developing an android app and you don't want to use Java, you might want to consider Kivy http://kivy.org/#home
If you are talking about having a web server running on Android and then running your django web app on that web server itself, there's a duplicate answer here - Web Server for Android

Related

How to run Python Selenium script on Android device?

I have working Python script using Selenium (Windows), and I want run same script (with driver replacement) on android device. I found some info about Selendroid and Appium, but they seem to be used for connecting to Android devices, not to port code.
I'd be glad for help with this issue or some useful links to read about it.
Kivy Is the way do the thing which you want.
Kivy is the library which provides the platform to execute python, also kivy is open source so anyone can use that.
Github Link
Kivy Showcase link

Running Node.Js on Android

So I know this has been questioned quite a lot. To be exact for example in these questions:
Run NodeJs server in Android
How to run my node.js project on android?
and
NodeJS on IOS/Android
Every option presented has a problem though:
I want to run it on my normal device so I would like to avoid installing another OS on my Device
Work on JXCore was stopped last month and (maybe as a result) I couldn't get it to compile (see Can't install jxcore-cordova)
The Android Port of NodeJs Anode has not been worked on since 2014 and wasn't really maintained back then anyways
The second answer in the second thread I linked to mentioned there is an official node distribution for Android now but apart from a link to the Browse-Website of the latest dist I couldn't find any info on how to actually use it
I also saw this but it seems like the device has to be connected to a PC (or similar) to run the adb shell commands while I would like to make it as a separate App
With the time that past since these questions have been posted and as the "best option" JXCore seem to be now unusable:
Is there a way to run a node.js application (a server in my case) on an Android device?
if you're wondering why I'd want this: I made a WebApp with a Node.Js server and I now want a version you can launch locally from your phone without requiring an Internet connection. This means the server needs to run on an Android phone.
I just had a jaw-drop moment - Termux allows you to install NodeJS on an Android device!
It seems to work for a basic Websocket Speed Test I had on hand. The http served by it can be accessed both locally and on the network.
There is a medium post that explains the installation process
Basically:
1. Install termux
2. apt install nodejs
3. node it up!
One restriction I've run into - it seems the shared folders don't have the necessary permissions to install modules. It might just be a file permission thing. The private app storage works just fine.
Dory - node.js
Great New Application
No Need to root your Phone and You Can Run your js File From anywere.
node.js runtime(run ES2015/ES6, ES2016 javascript and node.js APIs in android)
API Documents and instant code run from doc
syntax highlighting code editor
npm supports
linux terminal(toybox 0.7.4). node.js REPL and npm command in shell
(add '--no-bin-links' option if you execute npm in /sdcard)
StartOnBoot / LiveReload
native node.js binary and npm are included. no need to be online.
Update instruction to node js 8 (async await)
Download node.js v8.3.0 arm zip file and unzip.
copy 'node' to android's sdcard(/sdcard or /sdcard/path/to/...)
open the shell(check it out in the app's menu)
cd /data/user/0/io.tmpage.dorynode/files/bin (or, just type cd && cd .. && cd files/bin )
rm node
cp /sdcard/node .
(chmod a+x node
(https://play.google.com/store/apps/details?id=io.tempage.dorynode&hl=en)
You can use Node.js for Mobile Apps.
It works on Android devices and simulators, with pre-built binaries for armeabi-v7a, x86, arm64-v8a, x86_64. It also works on iOS, though that's outside the scope of this question.
Like JXcore, it is used to host a Node.js engine in the same process as the app, in a dedicated thread. Unlike JXcore, it is basically pure Node.js, built as a library, with a few portability fixes to run on Android. This means that it's much easier to keep the project up to date with mainline Node.js.
Plugins for Cordova and React Native are also available. The plugins provide a communication layer between the JavaScript side of those frameworks and the Node.js side. They also simplify development by taking care of a few things automatically, like packaging modules and cross-compiling native modules at build time.
Full disclosure: I work for the company that develops Node.js for Mobile Apps.
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/
the tutorial of how to build NodeJS for Android https://github.com/dna2github/dna2oslab/tree/master/android/build
there are several versions v0.12, v4, v6, v7
It is easy to run compiled binary on Android; for example run compiled Nginx: https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You just need to modify code to replace Nginx to NodeJS; it is better if using Android Service to run node js server on the backend.
Node.js Frontend for Android
releases include signed apks
Android 4.4+
open source (GPLv2)
no root
frontend for Node.js for Mobile Apps by Janea Systems
which was announced earlier in this thread by one of its developers
which is a game-changer; great work!
at a high level:
the "exec in same process" tab:
includes a list of Node.js apps that are intended to run for a short period of time while the application remains open, and may only be executed one at a time
the "fork to separate process" tab:
includes a list of Node.js apps that are each executed in a separate foreground service in a distinct process, and are intended to hold long-running daemons (ex: various types of servers)

Run NodeJs server in Android

Is it possible to run NodeJs server in android device (like linux devices not android apps).
If possible please help me to do it.
And is it possible to start mongo server on Android device?
My devices:
RK3288 TV Box (android 4)
Asus fonepad 7 (android 5 root)
LG Optimus G (android 4 root)
Important!! I want to start a server app in android. because I have an unused android TV-Box and I want to use it in my home server
And I don't want to use it in APK files (to load html files in WebView s). I need nodejs server not javascript client with CommonJs and RequireJs
You might want to install a chrooted-linux on your android-device, as explained here.
In short, do this:
prepare linux-image
do this on any gnu+linux -device.
create a big file (>1 GB)
format it as a filesystem (eg. ext2)
mount it.
copy a distribution inside of it (e.g. with debootstrap)
copy loopdevice to android
mount it (root required)
maybe install busybox
attach some directories from the root-device to the host (usually dev, dev/pts, proc and sys )
chroot
install nodejs inside chroot
note: I have done something similar to my tf301 and it works like a charm. But when I start to use too much memory inside the chroot (e.g. when compiling an android-app), the host will crash. I have not yet experienced those crashes with node and I do not know, if other devices are affected by this.
Install jxcore, as explained here:
Express on Android
The script assumes that Apache Cordova and the Android SDK is installed on your system. If they are not, please refer to individual documentation on how to do this.
Plug an android device into a USB socket (with USB Debugging enabled), unless you want to run the application on the Android Emulator.
Download the script and save it into an empty folder. Run it with a sample folder name as an argument, for example “express sample”:
$ ./install_and_run.sh "express sample"
The Script can be found here.
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/

Developing Ruby on an Android tablet

I want to do Ruby development on an Android tablet, just like on any laptop. So, using vim, git, and rspec to run tests. So, I've found the following apps:
Vimtouch
Ruboto
Git (yes, it's an app)
Terminal Emulator (provides bash)
Each app works just fine. By itself. But, I don't know how to put it all together. I'm a bit of a newbie when it comes to how Android works. So, if anyone could help provide a writeup so that I can:
clone a github repository
edit files from that repository
run my tests
NOTE: I don't want to write an Android app. I want to use my tablet to do Ruby development.
The Android Scripting Environment said to plan on Ruby. Might be worth a check how far they got; at least they're tagged "JRuby" at Google Code. According to their project page:
Scripts can be run interactively in a terminal, in the background, or via Locale. Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported, and we're planning to add more.
this can be done
Compile Ruby and Nodejs for android
Install on device and configure with c/c++ ide (You can use
C4droid,CCTools,Terminal IDE.... for installing the expansion
modules on с/с++)

Running a Python app on real Android phone

In order to develop an Android app using Python, I need to install Python for Android and SL4A on my computer to be used with the Android emulator. My question is, when I distribute this app to actual users/phones, do the phones need to get Python for Android and SL4A explicitly? Or is the supporting infrastructure built into Android devices? Or is there a way to package the Python application where the users do not have to get SL4A and Python for Android in order to run the application?
Instructions on redistributing your script to run on devices other than your development one are here:
http://code.google.com/p/android-scripting/wiki/SharingScripts
You can wrap them in a template project and build a stand alone apk.
Your users have to install SL4A and the language plugin (python?) on their phones, this is not a built-in functionality.
Since the source code is available, it's possible to create combined application, which includes your scripts and SL4A/python code, but in my opinion this defies the purpose of scripting in the first place.

Categories

Resources