everyone!
I really need to get a content from a json file in the same folder as my main.py file. The problem is: Google Cloud Function can't run the open()
statement. As the following error appears:
No such file or directory: 'mytest.json'
Now, I'm uploading my files in the Cloud Storage, but I wish it in the Cloud Source. So, how can I get my json file content from the Cloud Source?
This is my code structure in the Cloud Source:
.
├── main.py
└── requirements.txt
└── mytest.json
mytest.json
{
'test': 'Hello World!'
}
main.py:
import json
with open('mytest.json', 'r') as testJson:
testDict = json.loads(testJson.read())
print(testDict['test'])