Running python script on EC2 using an android app - android

I have an android app that must execute python code in ec2 on demand. What is the best way to implement this?

Have a look at the remote management tool that amazon provides.
You can have you servers setup with the tools,the ssm agent and the script you need to execute. Then send a remote command to them through the sdk.
Check the related ssm java sdk and how you can utilize it with android.

Step to get started with Python as backend and Android:
Install MAMP, WAMP or LAMP etc on your local computer depending on OS. Install python separately if it's not already included.
Introduction to Flask and RESTful services : follow https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask.
Maintain your code in version control eg Git. It is also useful to streamline your code upload from local to server.
Get a server : Since you might have to install some modules/packages on your server I recommend to have server with root access. You can try AWS free tier for 12 months.
Install Apache/Ngnix, python, SQL, phpmyadmin and Git depending on OS you have bought from AWS to start serving.
Go to your server root (mostly /var/www/html/) and git clone your project repository and change your environment variables and configuration as per step 5.
Ideally you should check here that you are getting expected response for your requests . Use Postman to test post requests.
Now you can consume your web service on android using any networking library like retrofit or volley.
Let me know if you need clarity on any point. Happy coding.

Related

Implement OpenVPN in Android

I recently bought a VPS to create a VPN app but it looks like there is no tutorial anywhere about it.
I saw the ics-OpenVPN project on Github, but I have no idea how to use it!
All I want is to connect to a Linux server from my phone
First of all, install OpenVPN on your VPS server. Although I do not have experience to install OpenVPN on VPS server but I think you can follow this tutorial it looks easy https://www.skysilk.com/blog/2018/install-openvpn-linux-vps/
After complete your installation you will get the .ovpn configuration file. Now to connect with your VPN server from your android app you need an android client software like the ics-OpenVPN android client.
I have also developed an android VPN app based on OpenVPN library you can use my source code it is open source. The instruction of changing .ovpn file is given on the GitHub repository.
Github: https://github.com/ashraf789/Cake-VPN
Do it has to be VPN? Or does an sshconnection with porttunnel satisfy your needs? That is for example how i connect to services on remote servers. With the tunneled port you are able to map the port on the remote server to your local system and access via localhost:.

calling a local parse server over the internet

Let say that I have a parse server installed locally on my local machine can I use that server outside of the development process and use it while I am not connected to my local WiFi? Basically is there any way that I can get around having to use a service such as Mongodb or Heroku?
Yes. you can deploy your parse-server on heroku and any server than can run node.js.
parse-server-example is giving the option to install parse server on different platforms including heroku with a 1-click install.

how to make worklight server for android app

I created an android app in worklight with HTTP Adapter in Eclipse Juno, I want to publish to publish it, I used API on server say 192.168.1.14, what should I write instead of Localhost, how to make new server to make app live. cannot understand IBM documentation to create the server. I want a simple way to create the server or any link with stepwise what to do.
What server I need jsp or other pages.
Can I test that server locally like in Netbeans before publishing?
You develop your applications and adapters in MobileFirst Studio as you've done.
However, in order to serve your application to end users, you must purchase a license from IBM. Once you've done that you get access to download required files. When you have the files, the docs will make sense to you.
Ask your company to contact IBM.

Using MongoDB along with ionic android app

I am building an android app using the ionicjs framework. I have done the basic layout using ionic's creator that gives me the code for it when I export it.
Now, I have to authenticate the login and register information against the details in the database, which is MongoDB. My question is, how do I install MongoDB? Do I install via the command prompt like it says in the Mongodb website or do a npm install in the root folder of my project?
After the installation, how do I go about connecting to the DB and doing the authentication? I think I need to use a REST API for that.
It would be very helpful if someone points me in a direction. I am new to developing apps like this.
Thanks!
MongoDb is a server-side database. So you have to install it on a remote machine, You shouldn't connect database directly with the mobile application which runs on clients hand. It's totally insecure, anyone can reveal your database connection information (password, username) by simply decompiling the app.
So, As you figure out, right way is to create a REST API to retrieve and send data back and forth between the server and the application.
Create a backend services with a server-side technology that your are prefer. It could be PHP,Python,Java or whatever. The client side application should not depend on the server-side technology your are using. Server side technology should completely transparent to the client application. You can attain this by designing good REST API.

NodeJS on IOS/Android

Maybe what I'm about to ask is stupid, generally I don't have so experience with server-side.
I'm building an Angular web application, with nodeJS on the server-side.
I need that the server (Node.exe) will installed in the device itself (IOS/Android), and nodeJS will open a localhost socket to communicate with the device.
(According to nodeJS official web site, nodeJS only support windows/Mac OS/Linux)
It's possible to do that?
If not, there is another server can I install in the device?
Yes you can with JXCore (a fork of nodejs), more info in this link
Build Mobile Apps with JavaScript and the Node.js Ecosystem repository is in here.
And how to compile it is in here JXCore - How to Compile
But if you need it to be nodejs (not the last version) you can use this link to do what you need Building and running Node.js for Android
UPDATED 27-09-2018
Like someone has pointed out, that project is no longer maintained but I have found and alternative by Using Termux on an Android phone you can use nodejs / gcc / vim / etc and more tools to do many thing
This link show how to do it for nodejs ( and I have tested it on my phone ):
Building a Node.js application on Android - Part 1: Termux, Vim and Node.js
First install termux from playstore, of course.
I don't understand the point of using a server tool on the client side.
If your application should work with an offline mode, you should put all data and other in your client app (using cordova).
If your application works with an online mode the server side is needed to serve your data. Here you can setup a nodeJS API which provides routes for your application to have content to print.
I'm not sure I brought you the wanted answer, so can explain more the point of using a server tool on a client device?
What you are trying to achieve, turns your device into a server.
A server side language is meant to stay on the server.
I don't really see why you need to open a localhost socket on the device to communicate with itself. Is it for offline testing? You can do that since you have a computer and a device, and both are connected to the same network.
I believe a really good start would be understanding the concept of the Client-Server architecture first.
But in short, the proper way of implementing a Client-Server app using your chosen technologies would be:
A server should provide the client with answers to his requests.
So in Node.js (server-side), write whatever you want to communicate with your database (Create, Read, Update, Delete), do custom processing, etc...
and return a structured answer.
The client is expecting answers to his requests, and is supposed to handle the answers in code. So the program written in AngularJS (which is your client-side language) will be installed on devices.
The client has to know the format of the server's answer. Is it plain text? XML? JSON? ...
so you mean you would like to have an app can run some services via http?
not sure if iOS allows application with JS virtual machine executing code ...
and for Android
searching on Github and I find how to build NodeJS for Android
https://github.com/dna2github/dna2oslab/tree/master/android/build
Here is an example to run compiled Nginx binary on Android at https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You may modify a little more to replace Nginx to NodeJS. The code to run Nginx is not very nice; maybe you can try an Android Service to let the server run on backend on Android device.
Hope it is what you want.

Categories

Resources