Is it possible to run PHP/JavaScript on an Android server? - javascript

I've been tinkering to create an Android server now. Not an actual web server though; only one that would be accessible through WLAN connections to share files.
I've managed to build one using Apache HTTP libraries, thanks to this wonderful guide. However, now I wanna set up the game a lil' bit by running some scripts.
The question is, is it possible to do so?
I've tried googling for clues but that one above was the best I could find.

Related

Any way to create an application with the local web page as an interface?

A few days ago I decided to make my own "interface" to make it easier to organize (and work with) some of my personal files. You know when a lot of related data, pictures and links are right in front of you and you can change them in a couple of clicks, this is very convenient.
I started by studying HTML, CSS and JS, because I thought that the changes made to the local page would be saved somewhere on my PC so I can just run Index.html and do whatever I want. But they didn't. Refreshing the page erased all changes.
Using browser localstorage does not suit me, because if I change the browser, the data will be lost. I wanted it to just open with Index.html and work fine even if I change my browser or move the site folder to another computer.
Then I decided to learn more about server-side languages (such as PHP or Node.js) because they are directly related to databases, so I was hoping to save changes through them. But these languages required me to really open the server, with ip and port tracking. And I just wanted to open a local page through one file, without any ports or connections via the console. So this method scared me off quickly.
So is there an easy way to make a local page like this? Maybe I have not studied well one of the above methods and it has this opportunity?
Or the best I can hope for is a simple application that will use that local page as an interface to interact with data? I accidentally heard about this possibility a long time ago. Then I will ask you to give at least a hint as to which language to choose for this.
I don't understand well everything that lies outside of vanilla HTML, CSS and JS, so a complete study of a complex language like Java or Python will be too difficult for me, and the goal is not worth such a lot of effort.
I hope I understand correcly what you are trying to do.
If your goal is to make an application to manage your files, I think the simplest solution will be, as you said, to look into NodeJS and the File system api which will let you interact with your files through javascript code.
Your program will have to be in two part that will have to interact:
the "front" html page
the "back" nodejs script
The downside is that you'll have to go deeper into your study of the language to learn how to create the interactions you want between your html file and your NodeJS application.
However, there is no need to open your server to the web to make it work. The NodeJS application can be set to listen to requests from only the computer that runs it (localhost).
I obviously can't get too much into details without knowing precisely what you want to do but you'll probably have to learn to make a local server with node (search "nodejs http" or "nodejs express"), then make requests to it via the html page's scripts (search "ajax request").
What you need to look into are (web based) content management systems. like strapi or "grand old dame" WordPress.

NodeJS + Tampermonkey can they work together?

I am creating software that helps me and my colleagues to work on tickets at work, as our current software is really bad. At this moment I am using program that I wrote in Tampermonkey, it is giving information about queue and all other fancy stuff. But I reached limit of that, as website is a limitation, so I started to create website that could do much more, yet I am not sure how to connect it as when I am using Tampermonkey to create overlay with all needed data. My idea was to: 1) Gather all data by tampermonkey and send it to nodejs server. Node would keep array (that's all I need) locally and then I would be able to access it.
Is this possible, is this a correct approach? Unfortunately I am limited by options that I can use by company security policy.

Service Workers in Cordova Hybrid Mobile App

we have done extensive work to determine if there is ANY possible way or hack that anyone has figured out to get service workers working in a Cordova app (not using Ionic)? Ionic actually doesn't work with true service workers either but that's another thread.
Obviously, the service worker has to come from a trusted host 'HTTPS' and our build comes from local host on File:///
We have tried the whitelist plugin, and we are aware there is an iOS plugin (which we don't want to fuss with) until we know we can also get them working on Android. Has anyone found a creative hack to make this work, or has Cordova updated to support this API yet (as it's the future of development)?
Even if you have constructed a hack solution we'd like to hear. Considered using PouchDB to help with offline access but that really doesn't help us run server tasks off the main thread and in the background, additionally we worry it could conflict with SQLite which we also use.
This seems like the last posts on this were quite some time ago so if any Cordova or PhoneGap folks could chime in and help a client-side rendered local host implement these, much appreciated.

How to publish a Node.js Server online so that it is always accessible by an outside application

I have searched everywhere for a solution to this problem but for whatever reason I cannot find a clear answer as to how I can carry out this task.
I have built a very simple server with node.js that accesses two numbers from a website API and outputs them onto a localhost port on my computer as shown below:
My question is how can I take my server and make it accessible to applications without having to go into the command line and run the server file? Is there a way I can host it online instead of locally so that I can distribute the application and anyone with the application can pull from this server? What would be the best way to go about accomplishing this task?
Heroku is probably one of the easiest ways to get started with deploying the application: https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
However, if you are not familiar with git, Microsoft Azure Webapps is also another great option: https://tryappservice.azure.com/
They both offer free plans which should get you up and running fast!
Question 1: how can I take my server and make it accessible to applications without having to go into the command line and run the server file?
To start a node server you will always need to use the console. If you are not used to,it's time to start :) .
You will be using it not only for node servers but for administrating (almost) every server in the world.
Question 2: Is there a way I can host it online instead of locally ?
There are a lot of nodejs hosting platforms, you can choose between PaaS solutions or IaaS solutions ( AWS EC2, Digital Ocean, etc.) . Probability the easiest way to start ar PaaS services, in this blogbost you will find a good list of PaaS hosting providers. Some of them have free plans.
Take a look at Heroku. They have a free tier (with limitations) and a hobby tier for $7/month.
I have implemented that with Amazon AWS, they offer free option for a limited time, but still great because you have full control on the console, you should be careful while installing the machine on cloud, you have many guides online that you can follow for steps, this one for example has step by step info, try to follow the steps and you will be able to run your app and access it from any public network.

Javascript not working on downloaded websites

So recently I was looking at some well-designed websites, with the functionality that I want to achieve / learn.
However, the problem is, that even though I manage to download the complete website (most recently I was using Scrapbook from Firefox), the website is not fully functional. Seems like the JS isn't working..
For example, a page like this.
When downloaded, the animations, progressive loading etc. are missing. I am guessing it's using Ajax to communicate with the server then?
Or what's the reason? Is there a way to get it working?
Cheers.
Most probably this is due to some scripts needing to be served from a domain name instead of localhost (your local machine). Your best bet is to learn how to set up a local web server with a package like XAMPP or MAMP. This is useful way beyond serving downloaded sites to inspect how they work. You can actually have a complete development environment this way.
Bonus tip: check out sites like Code Academy to learn even more about the ins and outs of web programming languages.

Categories