Cpython Hops server - upload a csv (txt) file

Hi,

I’m working with Hops Cpython Flask server. My comment is reading the path of a CSV file (hs.HopsString) and reading it as a pandas dataframe, this information is critical for other computations. As a local host everything works fine, but when uploaded to a Heroku server, the file could not be found.

Is there a way to read or upload this file from the hops component into the app running on a remote flask server?

Best Regards,

You could pass the entire contents of the CSV file to the server by reading it into a string and then passing that string as an input to your server.

1 Like

Thank you @stevebaer,

It is sure a way to workaround, and will work fine with the CSV and probably with the epw file I’m also using. I still wondering if it’s possible to upload and download files via a grasshopper hops component. Is it possible to use a flask request-like way of uploading files? I’m not sure since we are not using rotes decorators or are using forms as input.

Uploading the contents of a file is the same as uploading a file. If you don’t want to upload the file every time, you could have an endpoint that takes the contents of a file and returns a unique identifier for the file. You could then have another endpoint that takes this identifier and uses it to reference you content that you have already uploaded.

I don’t believe Heroku lets you save data to disk so you would need to either keep this in memory or use one of the database services that Heroku provides to store this data.

1 Like