Reputation: 35
Recently I've made a twitter-bot using tweepy for my own need. Now to host it online 24x7, I first tried Heroku (couldn't add the credit/debit card), then pythonanywhere.com (I don't know why the console was shutting down after a day), then repl.it (the API keys were returning None from the .env file - though in my system it was running fine) and finally WayScript.com.
Now, here I encountered a new file type saying .secrets. I used .env for storing all the keys, but they were asking to save those credentials in the .secrets file. They also provide the .env file type. But it says that it is preferable to add those credentials in the .secrets file as they will be saved as an encrypted string in that case. Here is the screen view -
Now, if I use .env file, I can easily import the credentials using the code below -
import os
Secret_Key = os.environ['key']
But if I use a .secret file, then how the credentials will be called?
I appreciate any help you can provide.
Upvotes: 1
Views: 1528
Reputation: 390
You should use ws.environment to read values stored inside .secrets file. If you need to retrieve your API key you can do that as follow.
api_key = ws.environment['API_KEY']
Upvotes: 1