How so i reference a service json file

hey,

I’m facing an issue referencing a service json file my python script requires.

Ive tried ‘service.json’, ‘./service.json’, ‘.service.json’

the file is in the same repo as my code

I have no idea what I am doing but this should (hopefully, theoretically) work. If you are making a website with Flask or Django or something like that, you should have something like “current_app.root”(works in flask). If not,

import os
os.getcwd()

this should give you the current working directory and you can append your file.

path = os.getcwd() + “/service.json”

[Maybe try with /, \, no slash; as I said, I have no idea what I am doing]

An alternative method could be to go to your deployment’s console and type pwd. And you’ll get the working directory. And you can manually type in your file address. In Koyeb, I believe it is something like:
/workspace/service.json

Hey Shetty,

You sort of helped me fix this??

I followed your steps, they didn’t work, buuut, i got an interesting error,

Instance created. Preparing to start...
Instance is starting. Propagating network configuration...
Network configuration propagated
  File "/workspace/bot.py", line 13
    path = os.getcwd() + “/client.json”
                         ^
SyntaxError: invalid character '“' (U+201C)
Application exited with code 1. This usually indicates an application failure. Check that the command used to launch your application is correct.
  File "/workspace/bot.py", line 13
    path = os.getcwd() + “/client.json”

the path is clearly displayed in the error as workspace/bot.py.

all i needed to do was /workspace.client.json.

From one person who doesn’t know what they’re doing to another. Thank you !

And now I’m re reading your response and realizing you already told me it was ```/workspace/``

1 Like