smolcgi: allow STORAGE_PATH env var
This commit is contained in:
parent
d8ed7d2921
commit
d0154c4a40
|
@ -5,8 +5,8 @@ from pathlib import Path
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
|
|
||||||
def getenv(name):
|
def getenv(name, default=""):
|
||||||
return environ.get(name, "")
|
return environ.get(name, default)
|
||||||
|
|
||||||
|
|
||||||
gateway_interface = getenv("GATEWAY_INTERFACE")
|
gateway_interface = getenv("GATEWAY_INTERFACE")
|
||||||
|
@ -50,7 +50,8 @@ def get_storage_path():
|
||||||
script_filename = script_name.split("/")[-1]
|
script_filename = script_name.split("/")[-1]
|
||||||
path = getenv(f"GEMINI_{script_filename.upper()}_STORAGE")
|
path = getenv(f"GEMINI_{script_filename.upper()}_STORAGE")
|
||||||
if not path:
|
if not path:
|
||||||
path = f"/home/gemini/storage/{script_filename}"
|
storage_root = getenv("STORAGE_ROOT", "/storage")
|
||||||
|
path = f"{storage_root}/{script_filename}"
|
||||||
path = Path(path)
|
path = Path(path)
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
|
|
Reference in a new issue