i'm working on dashboard for a customer and i'd like to be able to execute script on my GCP Virtual Machine linux but from the API Javascript.
Already check : https://cloud.google.com/compute/docs/reference/rest/v1/
But there is nothing about manage and execute the script from the VM herself.
Then i'd like to know if someone already did something like this
Just be able to execute "python3 /home/.../MyScript.py" but from the Google API.
Like create html button with onclick and execute the script on the VM with this button, using js-api
(i'm already using the BigQuery API to execute request, and thats work correctly)
Thanks :-)
As of today, you will not be able to do what you are asking for. Nonetheless, I found out two options that might help you as a workaround:
1- On your app server install gcloud and execute shell or system command using your programming language (e.g. PHP).
2- Create a web trigger to execute the script on the GCE instance.
I hope this approach works for you.
Related
Good morning,
I have some functions to modify a google sheet file (with Apps Script) and I want to call them from my site, basically, I want to click on a form to send me to an excel sheet with some specific data (with a function already created), and I have no possibility to create or modify an existing database, it is a very closed environment (Zendesk).
I don't know how to implement it on a web that is not made with google services.
Thanks for your help.
The easier way to call a Google Apps Script function from an external app is by creating a web app using Google Apps Script, set to be executed as the owner.
I.E. the following is the code for a web app that call myFunction and return a string as response when is called by a HTTP GET request.
function doGet(){
myFunction();
return ContentService.createTextOutput('Put here your response');
}
You should make a web application deployment, set as be executed as you by anyone even anonymous. Then make the HTTP GET request by using the web application URL.
Instead of doGet you might use doPost to make your web app respond to HTTP POST requests. Also, you might use different settings, but you should provide the proper OAuth token.
For further details please read https://developers.google.com/apps-script/guides/web
Another option is to use the Google Apps Script API but this might require from to invest more time.
I am building a Cordova mobile app for Android and want to add an event listener to my client-side JavaScript such that a function is called whenever data is written to a section of my firebase database. I know this can be done in node using firebase-functions and the onWrite events. However in trying to follow the getting started documentation (https://firebase.google.com/docs/functions/get-started) for using the firebase CLI, I have hit a roadblock in that I am trying to write client side code, so I cant use
const functions = require('firebase-functions');
because of the "require". I am looking at work-arounds for this like using requirejs but I'm not sure this is appropriate as I don't know which scripts I am trying to load in order for the fire-base functions to work. Is there a better way to do this ? Or is it not appropriate to be trying to use firebase-functions with client side java-script in the first place?
Inexperienced developer so I was hoping there was an easier way then having to make a separate project to use as a server, and a better way than having the client ping the firebase database every second to see if it has updated. Any advice greatly appreciated.
You can't use firebase-functions on the client. It's only for use with backend code deployed to Cloud Functions.
Client code using the Firebase SDK doesn't have the same capabilities as Cloud Functions triggers. That is to say, you can't write client code that triggers the same way as a Realtime Database trigger. You will need to write your client code using the capabilities offered by the client SDK, which involves setting up listeners at locations of the database you're interested in.
I have two Bokeh apps (on Ubuntu \ Supervisor \ Nginx), one that's a dashboard containing a Google map and another that's an account search tool. I'd like to be able to click a point in the Google map (representing a customer) and have the account search tool open with info from the the point.
My problem is that I don't know how to get the data from A to B in the current framework. My ideas at the moment:
Have an event handler for the click and have it both save a cookie and open the account web page. Then, have some sort of js that can read the cookie and load the account.
Throw my hands up, try to put both apps together and just find a way to pass it in the back end.
The cookies idea might work fine. There are a few other possibilities for sharing data:
a database (e.g. redis or something else, that can trigger async events that the app can respond to)
direct communication between the apps (e.g. with zeromq or similiar) The Dask dashboard uses this kind of communication between remote workers and a bokeh server.
files and timestamp monitoring if there is a shared filesystem (not great, but sometimes workable in very simple cases)
Alternatively if you can run both apps on the same single server (even though they are separate apps) then you could probably communicate by updating some mutable object in a module that both apps import. But this would not work in a scale-out scenario with more than one Bokeh server running.
Any/all of these somewhat advanced usages, an working example would make a great contribution for the docs so that others can use them to learn from.
I have a php program/app which asks for input, generate an image and post th image link to user's timeline (processor.php). I used PHP SDK in posting to timeline since I am more familiar with PHP. Now, in my gallery.php, i want to show like buttons for each generated image. I am aware that i have no option but use JS SDK in making button. but is it fine if i use two different SDK's in a single app?
processor.php - PHP SDK
gallerry.php - JS SDK
thanks for your answer! I would love to try your suggetions too
There shouldn't be any problem using PHP and JS in the same application, quite a common use case. You would normally use PHP to create the Web Application structure, handle backend logic, and then use JS to handle UI events.
There's nothing special about combining the two, just create the Web page with JS as normal for the view, and use PHP to build it.
Hope this helps.
Yes, there is no problem, the two APIs are designed to work together. The PHP API is usually used to created the backend logic (for example OAuth implementation, posting and getting data, etc) and the JS API to handle user iniated events.
Also see this: https://stackoverflow.com/a/6728092/1107118 on how to handle login state. Normally the JS API is used for logging in too, and then with the PHP API you take the access token and do the backend actions.
I'm need to know can i connect db through javascript? Actually, the last action where i end is done through javacsript. Now, i need to make some entries(extracted through javascript) in the database where last action stops. How can this be done?
The answer depends on where the Javascript being run.
If you're asking about Javascript running in a browser directly accessing a database on a remote server then the answer is no. The best you can do is create a web service which updates the Database and call that via an XMLHTTPRequest object from you JavaScript. You would need to be very careful about what you offered via such a web service. If you allowed any SQL statements anybody could connect to your service and run DELETE FROM customer; or insert new user records or do anything ghastly.
If you're running JavaScript through the Windows Scripting Host via CSCRIPT.EXE or similar you can create ODBC objects and access the database that way.
If you're running JavaScript on a JVM I think you can use JDBC.
If you want to give more details I can be more specific.