Spaces:
Running
Running
axeronis
feat: Unified AI Brain 2.0 (Merged Knowledge Base & Persona, Removed /knowledge routes)
20ee727 Download backend/scripts/fix_env.py from axeronis/microfunnel-api: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/scripts/fix_env.py
- Command line
-
hf download hf://spaces/axeronis/microfunnel-api/backend/scripts/fix_env.py
-
curl -L -o fix_env.py https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/scripts/fix_env.py
1.04 kB
| import os | |
| env_path = ".env" | |
| key_line = "OPENAI_API_KEY=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" | |
| try: | |
| # Read existing content | |
| if os.path.exists(env_path): | |
| with open(env_path, "r", encoding="utf-8", errors="ignore") as f: | |
| lines = f.readlines() | |
| else: | |
| lines = [] | |
| # Check if key exists | |
| found = False | |
| new_lines = [] | |
| for line in lines: | |
| if line.strip().startswith("OPENAI_API_KEY="): | |
| new_lines.append(key_line + "\n") | |
| found = True | |
| else: | |
| new_lines.append(line) | |
| if not found: | |
| if new_lines and not new_lines[-1].endswith("\n"): | |
| new_lines[-1] += "\n" | |
| new_lines.append(key_line + "\n") | |
| # Write back | |
| with open(env_path, "w", encoding="utf-8") as f: | |
| f.writelines(new_lines) | |
| print("Fixed .env with UTF-8") | |
| except Exception as e: | |
| print(f"Error fixing .env: {e}") | |