Maxime Zed

@Zertyazertyu (2)
Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus Okay, thanks you ! I'll hope that it will be patched in future !

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus I got the same problem when I try to launch your repl

Traceback (most recent call last):
  File "main.py", line 15, in <module>
    print(".ENV USERNAME: " + USERNAME)
TypeError: must be str, not NoneType

The getenv function returns a None type when it fails (no .env file in this case)

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus Yes that's all the problem ! This is like the .env is existing only when the owner of the repl launches it from the edit page.. so annoying... If there are no alternative to getenv i unfortunally think that i'll use a flask server :-(

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus
Done, but same result; got a None (the path of .env is aslo undisplayed

On the repl that you made for me I got a similar result, even if I enter "abc" I got a wrong password message

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus

No problem, thanks for your help:

main.py

import dotenv
import os

dotenv.load_dotenv()

print(os.getenv("SECRET"))
print(dotenv.find_dotenv(".env"))

.env

SECRET=abc

requirements.txt

python-dotenv==0.10.2

When I launch the repl from my editing page i get a working output:

abc
/home/runner/.env

And "None" displays when it's used from https://brouillon-test-poubelle.zertyazertyu.repl.run/

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus
Hello !
I'm really sorry but your solution don't work as I want.
I created a main file with:

import dotenv
import os

dotenv.load_dotenv()

print(os.getenv("SECRET"))
print(dotenv.find_dotenv(".env"))

So the code worked for me in my own environnement, but when I try to launch it with the console link https://Brouillon-test-poubelle.zertyazertyu.repl.run the .env is hidden so there are no secret key and no file path...

I need that other peoples can use a login and password but without being able to easily read the file that contains login infos

Is there any solution for this specific case ? Or do i need to create a flask server ? It could be really annoying

Thanks for your patience

Python 3/ Secret Keys for everyone
posted to Ask by Zertyazertyu

@heyitsmarcus Thanks you for your help but the problem is that when somebody launches the program on https://brouillon-test-poubelle.zertyazertyu.repl.run/ for example the .env is not imported so i've got the wrong password message (the .env contains SECRET=kok). I need a program that hide the .env or other other file for others but that can be read by the console of no owners users ( know that if the program reads the file, it's imported but this is a game soft not a nasa one so security is not very important while password file is hidden)

But thanks you for your response !