repl.it
@heyitsmarcus/

Load from .env

Python

No description

fork
loading
Files
  • main.py
  • Packager files
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#THESE LINES ARE NECESSARY TO IMPORT FROM .env FILE
from dotenv import load_dotenv
import os

load_dotenv()

#my .env has 2 keys that look like this:
#USERNAME="test"
#PASSWORD="secretpass"

#so now I'm grabbing USERNAME AND PASSWORD from the .env file
USERNAME = os.getenv("USERNAME")
PASSWORD = os.getenv("PASSWORD")

print(".ENV USERNAME: " + USERNAME)
print(".ENV PASSWORD: " + PASSWORD)

#enter test for username as the input to test
inputUsername = input("Enter username: ")
if inputUsername == USERNAME:
	inputPassword = input("Password: ")
	#enter secretpass as password
	if inputPassword == PASSWORD:
		print("You're in.")
	else:
		print("Not today, Satan. Bad password.")
else:
	print("Not today, Satan.")