[Python] How to run Open-WebUI as a python app without using the open-webui.exe (what does it...

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I want to run open-webui as a Python app, like starting it with python xxx.py but I don't see how. it's seems to be all in Python but there is a mysterious (to me) open-webui.exe that runs first presumably sets some things, and then invokes other Python functions from other modules. It is possible to run it only from Python or is the source of this .exe released? Here's my startup script so far, but it is failing since it doesn't know the locations of files, databases, etc. There is an env.py but no .env that I can find to determine the locations.

    # -*- coding: utf-8 -*-
    """
    Created on Wed Jan 22 16:48:51 2025
    @author: E21131490
    """
    import uvicorn
    import os
    from pathlib import Path

    try:
    from open_webui.env import DATABASE_URL, DATA_DIR
    from open_webui.main import app

    print(f"Using database at: {DATABASE_URL}")
    print(f"Data directory: {DATA_DIR}")

    if __name__ == "__main__":
    uvicorn.run(
    app,
    host="0.0.0.0",
    port=int(os.getenv("PORT", 8080)),
    log_level="info"
    )
    except ImportError as e:
    print(f"Failed to import required modules: {e}")
    print("Please ensure open-webui is installed correctly")

    Continue reading...

Compartilhe esta Página