fix: Remove hardcoded ports, support custom port configuration
- Replace all hardcoded localhost:8000/3000/8501 with environment variables - Frontend: Use API_PORT env var in next.config.ts - Backend: Use API_PORT env var in editor.py and quality.py - Web UI: Use API_PORT and EDITOR_PORT env vars in all Streamlit pages - Update dev.sh to pass environment variables to all services - Add .env.example with port configuration template Now supports custom ports via environment variables: API_PORT=8080 EDITOR_PORT=3001 WEB_PORT=8502 ./dev.sh Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,10 @@ from web.utils.async_helpers import run_async
|
||||
from pixelle_video.models.progress import ProgressEvent
|
||||
from pixelle_video.config import config_manager
|
||||
|
||||
# Get ports from environment
|
||||
API_PORT = os.getenv("API_PORT", "8000")
|
||||
EDITOR_PORT = os.getenv("EDITOR_PORT", "3000")
|
||||
|
||||
|
||||
def render_output_preview(pixelle_video, video_params):
|
||||
"""Render output preview section (right column)"""
|
||||
@@ -135,7 +139,7 @@ def render_single_output(pixelle_video, video_params):
|
||||
|
||||
# Submit to async API
|
||||
response = requests.post(
|
||||
"http://localhost:8000/api/video/generate/async",
|
||||
f"http://localhost:{API_PORT}/api/video/generate/async",
|
||||
json=api_payload,
|
||||
timeout=30
|
||||
)
|
||||
@@ -309,7 +313,7 @@ def render_single_output(pixelle_video, video_params):
|
||||
pass
|
||||
|
||||
if task_id:
|
||||
editor_url = f"http://localhost:3000/editor?storyboard_id={task_id}"
|
||||
editor_url = f"http://localhost:{EDITOR_PORT}/editor?storyboard_id={task_id}"
|
||||
st.markdown(
|
||||
f'''
|
||||
<a href="{editor_url}" target="_blank" style="text-decoration: none;">
|
||||
|
||||
@@ -33,6 +33,9 @@ from web.components.header import render_header
|
||||
from web.i18n import tr
|
||||
from web.utils.async_helpers import run_async
|
||||
|
||||
# Get ports from environment
|
||||
EDITOR_PORT = os.getenv("EDITOR_PORT", "3000")
|
||||
|
||||
# Page config
|
||||
st.set_page_config(
|
||||
page_title="History - Pixelle-Video",
|
||||
@@ -363,7 +366,7 @@ def render_task_detail_modal(task_id: str, pixelle_video):
|
||||
)
|
||||
|
||||
# Open in Editor button
|
||||
editor_url = f"http://localhost:3000/editor?storyboard_id={task_id}"
|
||||
editor_url = f"http://localhost:{EDITOR_PORT}/editor?storyboard_id={task_id}"
|
||||
st.markdown(
|
||||
f'''
|
||||
<a href="{editor_url}" target="_blank" style="text-decoration: none;">
|
||||
|
||||
@@ -22,6 +22,7 @@ Features:
|
||||
import streamlit as st
|
||||
import requests
|
||||
import time
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from web.i18n import tr, get_language
|
||||
@@ -33,8 +34,12 @@ st.set_page_config(
|
||||
layout="wide",
|
||||
)
|
||||
|
||||
# Get ports from environment
|
||||
API_PORT = os.getenv("API_PORT", "8000")
|
||||
EDITOR_PORT = os.getenv("EDITOR_PORT", "3000")
|
||||
|
||||
# API endpoint
|
||||
API_BASE = "http://localhost:8000/api"
|
||||
API_BASE = f"http://localhost:{API_PORT}/api"
|
||||
|
||||
|
||||
def get_all_tasks():
|
||||
@@ -183,7 +188,7 @@ def render_task_card(task):
|
||||
with col_a:
|
||||
st.success("✨ 视频生成成功")
|
||||
with col_b:
|
||||
editor_url = f"http://localhost:3000/editor?storyboard_id={task_id}"
|
||||
editor_url = f"http://localhost:{EDITOR_PORT}/editor?storyboard_id={task_id}"
|
||||
st.markdown(
|
||||
f'''
|
||||
<a href="{editor_url}" target="_blank" style="text-decoration: none;">
|
||||
|
||||
Reference in New Issue
Block a user