To relate better to this, do give this a read!
The most important component of REMO, a solution built for the conduction of remote interviews is the virtual environment. Testing of technical skills for any interview is a must. Often candidates are asked to share their screens, give remote access to the interviewers or explain their logic orally, all of these practices hinder clear expression and flow of thoughts and also go against respecting the privacy of the candidate. Our solution is to provide a resource created on the cloud, such that the candidate as well as an interviewer have access to it. Any software resource can be created and used.
Nuvepro Technologies is a startup based out of Bangalore. They are a provider of cloud labs and resources. They provided us with a set of APIs through which we could create a resource on the cloud. Their APIs provide a layer of abstraction in the sense, that they interact with the cloud-service providers like AWS, Azure, GCP, and so on. These API’s when called with a few specifications and parameters can be used to create a resource on the cloud.
As stated earlier, the virtual environment was a component of the solution REMO. Thus, it had to come up as a UI element. As newbies, the immediate thought process was to make use of JavaScript and call these APIs. And so these were the first steps we took. We learned about the various methods of making a GET request in JavaScript using fetch, XMLHttpRequest, and so on.
The first API call returned a successful response, but for further progress, the API’s needed cookies to be passed. However, we were not successful in passing cookies, or rather the browser refused to make these further requests due to the Cross-Origin-Resource-Sharing policy, commonly known as CORS. This is a security policy implemented across the browser. The reason was because the domain where the service was hosted (Nuvepro’s servers ) and the domain from which it was being called (my local machine) were different. So this option had to be eliminated.
On talking to a few experts, it occurred that a middleware (or a server that mediates between Nuvepro’s Server and the machine invoking the APIs had to be set up). Express is a framework based on JavaScript which is used as middleware. However, considering Python’s widespread applications, calling the APIs using Python was another option. Flask was used to setup a server, this served as the middleware. This was a successful idea, the only roadblock was passing cookies in the correct format, i.e {name_of_Cookie : value_of_Cookie}, this is the required format, which took a while to figure out. There were six API’s that needed to be called for the successful creation of a resource on the cloud (Henceforth resource refers to an instance of an Ubuntu Machine on the cloud). The total time taken for the successful creation of a resource is close to 5–7 minutes (based on the network traffic). These API’s returned a successful response and we were able to embed it in an iframe.
To be a component of REMO, it had to be integrated into the application. i.e, when an interview was scheduled the resource had to be created. So the next requirement was to host this set of APIs so it could be invoked by our application. Since we were working with Python, we came across Zappa, integration with Amazon Web Services. The Python scripts can directly be hosted on an S3 instance on AWS. Another option was to use Google Cloud Platform and host the scripts with the Python App Engine. Another was to host is on Heroku or even Microsoft Azure. We tried all of these methods, but they failed. As stated earlier, the API call needed 5- 7 minutes to yield a 200 response (successful response). However, these hosting services had a timeout duration of a maximum of 1 minute.
The ultimate solution was to create a virtual machine on one of the cloud providers and run the scripts just like how it was run locally. Considering the 300 dollar credit for new accounts on Google Cloud Platform, a VM was created on GCP using Compute Engine, the python scripts were run, and it ran on the localhost of the VM, however, accessing it outside needed a public URL. To resolve this, the ngrok service was used, it can generate a public URL when specified with a port on which an application is running. By making use of a public URL, the resource was accessible and could be created.