41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import argparse
|
|
import os
|
|
import uvicorn
|
|
from open_webui import app
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="GlowPath Backend Server")
|
|
parser.add_argument(
|
|
"--port", type=int, default=8080, help="Port to run the server on"
|
|
)
|
|
parser.add_argument(
|
|
"--host", type=str, default="127.0.0.1", help="Host to bind the server to"
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
# Set up Open WebUI environment variables if they're provided
|
|
# These will be set by the Tauri app for proper data persistence
|
|
data_dir = os.environ.get("DATA_DIR")
|
|
if data_dir:
|
|
print(f"Using data directory: {data_dir}")
|
|
# Ensure the data directory exists
|
|
os.makedirs(data_dir, exist_ok=True)
|
|
|
|
# Set additional Open WebUI environment variables for persistence
|
|
os.environ.setdefault("WEBUI_DATA_DIR", data_dir)
|
|
os.environ.setdefault("WEBUI_UPLOAD_DIR", os.path.join(data_dir, "uploads"))
|
|
os.environ.setdefault("WEBUI_CACHE_DIR", os.path.join(data_dir, "cache"))
|
|
|
|
# Create subdirectories
|
|
os.makedirs(os.environ["WEBUI_UPLOAD_DIR"], exist_ok=True)
|
|
os.makedirs(os.environ["WEBUI_CACHE_DIR"], exist_ok=True)
|
|
|
|
# Run the FastAPI app using uvicorn
|
|
uvicorn.run(app, host=args.host, port=args.port, log_level="info")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|