Fix if folder does not exist

This commit is contained in:
Khrysse 2025-06-22 13:10:36 +02:00
parent 80ada82cb5
commit d1dd755193
2 changed files with 7 additions and 3 deletions

View File

@ -6,13 +6,13 @@ import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parent.parent))
from env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER, ACCOUNT_JSON_URL, ACCOUNT_JSON_TOKEN
from app.env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER, ACCOUNT_JSON_URL, ACCOUNT_JSON_TOKEN
if IS_RENDER:
import requests
print("⚠️ Running in Render environment, downloading account.json with token in URL...")
url = f"{ACCOUNT_JSON_URL}?token={ACCOUNT_JSON_TOKEN}"
url = f"{ACCOUNT_URL_JSON}?token={ACCOUNT_JSON_TOKEN}"
try:
response = requests.get(url)
@ -21,10 +21,14 @@ if IS_RENDER:
print(f"❌ Failed to download account.json: {e}")
sys.exit(1)
Path(TOKEN_FILE).parent.mkdir(parents=True, exist_ok=True)
with open(TOKEN_FILE, "wb") as f:
f.write(response.content)
print("✅ account.json downloaded successfully.")
sys.exit(0)
def save_token(data):
data["created_at"] = datetime.now(timezone.utc).isoformat()

2
run.py
View File

@ -43,7 +43,7 @@ def main():
print("Virtual environment found.")
print("Running VRChat authentication script...")
run_in_venv(["app/prelaunch/vrchat_auth.py"])
run_in_venv(["prelaunch/vrchat_auth.py"])
print("Starting FastAPI server...")