first commit
This commit is contained in:
46
start_frontend.sh
Normal file
46
start_frontend.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# start_frontend.sh - 启动前端测试页面静态服务
|
||||
|
||||
set -e
|
||||
|
||||
FRONTEND_DIR="frontend"
|
||||
PORT=${FRONTEND_PORT:-3000}
|
||||
|
||||
echo "========================================"
|
||||
echo "启动前端测试页面服务"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# 检查前端目录
|
||||
if [ ! -d "$FRONTEND_DIR" ]; then
|
||||
echo "错误: 前端目录不存在: $FRONTEND_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查index.html
|
||||
if [ ! -f "$FRONTEND_DIR/index.html" ]; then
|
||||
echo "错误: 前端页面不存在: $FRONTEND_DIR/index.html"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "前端地址: http://localhost:$PORT"
|
||||
echo ""
|
||||
echo "确保API服务已启动:"
|
||||
echo " ./start_api.sh"
|
||||
echo ""
|
||||
echo "正在启动前端服务..."
|
||||
|
||||
# 使用Python内置HTTP服务器
|
||||
cd $FRONTEND_DIR
|
||||
|
||||
# 查找Python命令
|
||||
if command -v python3 &> /dev/null; then
|
||||
PYTHON_CMD=python3
|
||||
elif command -v python &> /dev/null; then
|
||||
PYTHON_CMD=python
|
||||
else
|
||||
echo "错误: 未找到Python"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$PYTHON_CMD -m http.server $PORT --bind 0.0.0.0
|
||||
Reference in New Issue
Block a user