mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 07:51:51 +09:00
32 lines
954 B
Python
32 lines
954 B
Python
# save ./data/target.temp file as domain string
|
|
import os
|
|
|
|
def save(target: str, file_path: str = "./data/target.dump") -> None:
|
|
"""
|
|
Save the target domain to a temporary file.
|
|
|
|
:param target: Target domain to be saved.
|
|
"""
|
|
# Create directory if it doesn't exist
|
|
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(target)
|
|
|
|
print(f"Target saved to {file_path}") # Debug message
|
|
|
|
def load(file_path: str = "./data/target.dump") -> str:
|
|
"""
|
|
Load the target domain from a temporary file.
|
|
|
|
:return: Target domain string.
|
|
"""
|
|
if not os.path.exists(file_path):
|
|
print(f"[ERROR] Target file {file_path} does not exist.")
|
|
return ""
|
|
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
target = f.read().strip()
|
|
|
|
print(f"Loaded target from {file_path}: {target}") # Debug message
|
|
return target
|