Python + Node.js on GAE - python

I have a Django application deployed on Google App Engine standard environment. I am interested in server side rendering of my JS frontend. Can I use node.js alongside Django on the same GAE? Maybe as microservice?

What you can do is to deploy each of your app as a separate service in App Engine and they will work independently as a microservice. To do so, make sure to set a service name for each of the app.yaml file of your apps:
service: service-name
Afterwards, you can communicate between your services through an HTTP invocation, such as a user request or a RESTful API call. Code in one service can't directly call code in another service.
Refer to this link for additional information about communicating between your services.

I have come across articles that talk about integrating python and Node but I personally haven't done it or seen it done on GAE.
If I were to take a stab, I think you would be looking at something like
Have the python app as a service (say it's available on python_service.myapp.appspot.com
Have your Node.js as your default service available on myapp.appspot.com
Your Nodejs will have a route and when this route is invoked, you make an http request to the python service, wait for a response and then your Nodejs app returns that response.
Our App, https://nocommandline.com is an Electron App (combo of Node.js & Vue.js) If you purchase a license and try to validate it, we make a call server side and our server side is Python based. It's not exactly the same thing you're looking at (since our App is not web-based) but this gives you an idea of what I was trying to describe.

Related

Can I deploy my Django application only using nginx or Gunicorn?

I knew that for deploying a Django application we have to use a combination of uWSGI + Nginx or Nginx + Gunicorn server. Is that necessary? I have a small doubt here. Can we deploy the entire application only in Nginx or only in Gunicorn? Will, it not work? Just for an example(leaving production) can't I do that?
For a full pledge application you need both web server and app server. Web server such as nginx or apache deliver static content but app server delivers dynamic content. Major differences between a web server and app server are:
A web server accepts and fulfills requests from clients for static content (i.e., HTML pages, files, images, and videos) from a website. Web servers handle HTTP requests and responses only.
An application server exposes business logic to the clients, which generates dynamic content. It is a software framework that transforms data to provide the specialized functionality offered by a business, service, or application. Application servers enhance the interactive parts of a website that can appear differently depending on the context of the request.
To know more please follow these link:
https://www.ibm.com/cloud/learn/web-server-vs-application-server
https://www.educative.io/edpresso/web-server-vs-application-server
YES , you can. NO, you shouldn't.
If you run your app (in my case Django), on its development server. You can access it from a remote computer at its ip_address:port_number which should look something like 123.142.524.110:8000 and you can see your app at work.
You can also run Django with only gunicorn, it will still lack the web servers capabilities like sering static files efficiently or handling slow clients or DDOS handling. But it will run and that is all I can promise.
Unsure of whether Nginx can be directly tried with DJANGO app server, but I don't see why not. <<Probably someone else can attest to having successfully 'tried' it>>
I should repeat again, just coz its possible doesn't mean you should do it.

Running One Instance of Google App Engine with frontend in nodejs and backend server in python

I'm getting my feet wet with GCP and GAE, also nodejs and python and networking (I know).
[+] What I have:
Basically I have some nodejs code that takes in some input and is supposed to then send that input to some python code that will do more stuff to it. My first idea was to deploy the nodejs code via GAE, then host the python code in a python server, then make post requests from the nodejs front-end to the python server backend.
[+] What I would like to be able to do:
just deploy both my nodejs code and my python code in the same project and instance of GAE so that the nodejs is the frontend that people see but so that the python server is also running in the same environment and can just communicate with the nodejs without sending anything online.
[+] What I have read
https://www.netguru.co/blog/use-node-js-backend
Google App Engine - Front and Backend Web Development
and countless other google searches for this type of setup but to no avail.
If anyone can point me in the right direction I would really appreciate it.
You can't have both python and nodejs running in the same instance, but they can run as separate services, each with their own instance(s) inside the same GAE app/project. See Service isolation and maybe Deploying different languages services to the same Application [Google App Engine]
Using post requests can work pretty well, but will likely take some effort to ensure no outside access.
Since you intend to use as frontend the nodejs service you're limited to using only the flexible environment for it, which limits the inter-service communication options - you can't use push queues (properly supported only in the standard environment) which IMHO would be a better/more secure solution than post requests.
Another secure communication option would be for the nodejs service to place the data into the datastore and have the python service pick it up from there - the datastore is shared by all instances/versions/services inside the same GAE app. Also more loosely coupled IMHO - each service can function (at least for a while) without the other being alive (not possible if using the post requests).
Maybe of interest: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment
UPDATE:
Node.JS is currently available in the standard environment as well, so you can use those features, see:
Now, you can deploy your Node.js app to App Engine standard environment
Google App Engine Node.js Standard Environment Documentation

appengine frontend to kubernetes

I'm trying to setup a flask app on google app engine that will be something of a frontend management console for google container engine. Google has put out working APIs to spin up a container cluster, but it does not look like they have put out (python) APIs to administer kubernetes. That is, everything needed implement services, pods, RCs etc. seems to be setup to run through bash scripting. This is not compatible with the restrictions of google's app engine.
Is there a commonly accepted solution/package for this? Would it make more sense to abandon appengine in favor for a managed VM (not ideal)?
Thanks
As I mentioned in Submit jobs using API Client Library for Python?, the Kubernetes API uses a standard swagger specification, so it should be possible to generate a python client library. There is also pykube if you want to experiment with a existing client library.

Processing data from Google App Engine on a Google Virtual Machine

My website runs on Python on Google App Engine, and I've setup a Virtual Machine to use libraries that weren't supported by the default App Engine environment. Now I need to send data from my app to the VM and retrieve the response. Data in this case will be an email address and an email message.
Currently I am testing with a POST request through urllib2. Is there a better way to do this?
Sticking with the described POST request using urllib2. We decided we might move this part of the project to a different provider so better to not use Google Cloud only methods.

Do I need Google App Engine to make and run a Facebook App?

I set up the Google App Engine on my computer to work with Python , so I could make my first "Hello World" App at http://localhost:8080/. In the developers section of facebook it says I need Google App Engine and Python to test an app. But my question is, can I just host the files(the .yaml and the .py) on my server account instead(once I'm done testing)?
You do not specifically need Google app engine, that i believe is just a sample app. The main thing that you need is a globally accessible web server. So that FB can reach your pages/application from their servers. So depending on the language, get a small/free hosting account and test your application from there. Or you may also try Dynamic DNS to be able to reach your local machine from the outside world http://www.dyndns.com/services/dns/dyndns/
That example is written in Python and specifically targeted for Google App Engine. So, yes you do need Google App Engine to run that example without modification. However, almost any web hosting would suffice in general with your own application.

Categories

Resources