Ask coding questions

← Back to all posts
Cant create .env and using secret key isnt working
Gizdox (0)

Hello. I'm a newbie to replit and I am trying to code a discord bot. However, I am stuck on creating an .env since they have just recently changed how you're supposed to use it. How am I supposed to create an .env to put my token in?


PYer (4013)

The environmental variable system has changed recently. There should be a lock icon on the left hand side bar, with multiple other options, including the file tree, and package manager. Then, there should be a simple input field asking you for the key and value of the secret you are adding. Then you should be able to access it as you have in your code (os.getenv('TOKEN'), provided that they key for the secret is TOKEN).

InvisibleOne (2934)

On the left side of your screen click on the secrets tab (next to package manager, database, etc) and then create a new secret. Give it a name and value, and then you can either use the generated code to bring it into your project, or access it these same way you would a .env file with