Skip to content

Instantly share code, notes, and snippets.

@patmigliaccio
Created April 24, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmigliaccio/8bb1747c879e337f442b371cb3414f8f to your computer and use it in GitHub Desktop.
Save patmigliaccio/8bb1747c879e337f442b371cb3414f8f to your computer and use it in GitHub Desktop.
decodes an `ENV_FILE` env variable from a base 64 string in a .env file
import os
import base64
encoded_env_file = os.environ.get("ENV_FILE")
if encoded_env_file != None:
decoded_env_file = base64.b64decode(encoded_env_file).decode('utf-8')
with open("./" + str(os.environ.get("FILE_NAME", ".env")), "w") as text_file:
text_file.write(decoded_env_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment