Referencing a file local to a Python File

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Referencing a file local to a Python File



I have been experimenting with the Python Cloud Functions. One of my cloud functions utlizies a large text file, that I would love to bundle with my .py file when I deploy it. THe docs are kinda limited on stuff like this..



https://cloud.google.com/functions/docs/quickstart



I was looking, would I just include that file, and a requirements file in my same directory as my function to deploy it. Or do I have to some how require it in my code?



Also, is there any information on how to use a database trigger instead of a http trigger? I was trying to think if the reason my file didn't seem to get included was because I had the wrong way of defining the trigger. How would you create an OnCreate.. or something like that


gcloud beta functions deploy hello_get --runtime python37 --trigger-http





Triggers on Firebase products are not currently supported for python. You have to write those in JavaScript or TypeScript targeting node.js.
– Doug Stevenson
Aug 8 at 3:44





@Doug must be really new then.. in google cloud console you can create them for firebase products
– billybob2
Aug 8 at 3:47




1 Answer
1



When you deploy your function using gcloud, your project directory is zipped and uploaded. Any files contained in the current directory (and child directories) will be uploaded as well, which includes static assets like your large text file.


gcloud



Just make sure your text file is in your project directory (or one of the child directories), then use a relative reference to your file in your Python code. It should just work.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard