优化sys.path逻辑
This commit is contained in:
10
api/app.py
10
api/app.py
@@ -22,6 +22,16 @@ Or with custom settings:
|
|||||||
uv run python api/app.py --host 0.0.0.0 --port 8080 --reload
|
uv run python api/app.py --host 0.0.0.0 --port 8080 --reload
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Add project root to sys.path for module imports
|
||||||
|
# This ensures imports work correctly in both development and packaged environments
|
||||||
|
_script_dir = Path(__file__).resolve().parent
|
||||||
|
_project_root = _script_dir.parent
|
||||||
|
if str(_project_root) not in sys.path:
|
||||||
|
sys.path.insert(0, str(_project_root))
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|||||||
11
web/app.py
11
web/app.py
@@ -16,10 +16,19 @@ Pixelle-Video Web UI
|
|||||||
A simple web interface for generating short videos from content.
|
A simple web interface for generating short videos from content.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Add project root to sys.path for module imports
|
||||||
|
# This ensures imports work correctly in both development and packaged environments
|
||||||
|
_script_dir = Path(__file__).resolve().parent
|
||||||
|
_project_root = _script_dir.parent
|
||||||
|
if str(_project_root) not in sys.path:
|
||||||
|
sys.path.insert(0, str(_project_root))
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|||||||
Reference in New Issue
Block a user