def ensure_secret():
home_dir = os.environ['<STR_LIT>']<EOL>file_name = home_dir + "<STR_LIT>"<EOL>if os.path.exists(file_name):<EOL><INDENT>with open(file_name, "<STR_LIT:r>") as s_file:<EOL><INDENT>secret = s_file.readline()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>secret = os.urandom(<NUM_LIT>)<EOL>with open(file_name, "<STR_LIT:w>") as s_file:<EOL><INDENT>secret = s_file.write(secret+"<STR_LIT:\n>")<EOL><DEDENT><DEDENT>return secret<EOL>
Check if secret key to encryot sessions exists,
    generate it otherwise.