Create remember.py
Browse files- remember.py +21 -0
remember.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
FILE_PATH = "remember_user.json"
|
| 5 |
+
|
| 6 |
+
def save_email(email):
|
| 7 |
+
try:
|
| 8 |
+
with open(FILE_PATH, "w") as f:
|
| 9 |
+
json.dump({"email": email}, f)
|
| 10 |
+
except:
|
| 11 |
+
pass
|
| 12 |
+
|
| 13 |
+
def load_email():
|
| 14 |
+
try:
|
| 15 |
+
if os.path.exists(FILE_PATH):
|
| 16 |
+
with open(FILE_PATH, "r") as f:
|
| 17 |
+
data = json.load(f)
|
| 18 |
+
return data.get("email", "")
|
| 19 |
+
except:
|
| 20 |
+
pass
|
| 21 |
+
return ""
|