Hops flask server call via cloud

Hello McNeel Forums!

I am looking to call a cloud-hosted Cpython function from a hops component. I emulated the local flask server implementation demonstrated in the Hops Tutorial which runs smoothly. In an attempt to emulate a full AWS cloud implementation of a Cpython server (via Lambda or hosting the flask app via EC2, presuambly) I used ngrok to expose my local server to the internet, using the ngrok url (to my locally hosted flask server) as the endpoint in the hops component.

In order to prevent the default disabled loading from remote sources if hosted on a (ngrok) server, I added loadFromRemoteSources enabled="true" to the Rhino executable configuration file, but though this resolved the initial error I found from exporting the REST API/python sample outputs from the hops component, the component still did not work. I also tried adding a test API key via grasshopper solver settings, to no avail.

My question is how best to host (a flask-based, hops-decorated) Cpython server online and call it from within grasshopper? Does this involve any special permissioning, potentially accomplished through grasshopper setting-Solver, or am I barking up the wrong tree?
Any help much appreciated! :smiley:

@stevebaer would you happen to know of any examples running a hops component without using localhost?
I know of using Rhino Compute AppServer (with or without Heroku), and think I’ve googled and looked through all related discussions to the original Hops Component post but cannot find any such examples.
Many thanks!

I’m not very familiar with ngrok. I know what it is and what it is used for, but haven’t personally used it. Are you able to hit your flask server from your browser? Make a hello world GET endpoint in flask and make sure you can hit it from a browser or curl.

I added and tested a hello world GET endpoint to the flask app. When testing the endpoint in a browser, I clicked to allow traffic (bypass Ngrok browser warning) which was likely what held up the hops component execution previously.

That is to say, it works! The fault lay in my test; forwarding via ngrok free tier without bypassing browser warning first.

Thanks for the help.