codedetect/start_server.sh

53 lines
1.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "CodeDetect 工作空间启动脚本"
echo "================================"
# 检查Python3
if ! command -v python3 &> /dev/null; then
echo "错误: 未找到Python3请先安装Python3"
exit 1
fi
# 检查Flask是否已安装
if python3 -c "import flask" 2>/dev/null; then
echo "✅ Flask已安装启动完整工作空间..."
cd /home/hzk/桌面/Codedetection
echo "🚀 启动简化版Flask服务器..."
python3 simple_app.py
else
echo "❌ Flask未安装尝试安装..."
# 尝试安装Flask
if command -v pip3 &> /dev/null; then
echo "使用pip3安装Flask..."
pip3 install --user Flask
elif python3 -m pip --version &> /dev/null; then
echo "使用python3 -m pip安装Flask..."
python3 -m pip install --user Flask
else
echo "未找到pip尝试使用系统包管理器..."
echo "在Ubuntu/Debian上运行: sudo apt-get install python3-flask"
echo "在CentOS/RHEL上运行: sudo yum install python3-flask"
echo "Flask安装失败启动静态文件服务器..."
cd /home/hzk/桌面/Codedetection/src/ui/templates
echo "静态服务器启动在: http://localhost:8000"
echo "按Ctrl+C停止服务器"
python3 -m http.server 8000
exit 0
fi
# 重新检查Flask
if python3 -c "import flask" 2>/dev/null; then
echo "✅ Flask安装成功启动服务器..."
cd /home/hzk/桌面/Codedetection
python3 simple_app.py
else
echo "❌ Flask安装仍然失败启动静态服务器..."
cd /home/hzk/桌面/Codedetection/src/ui/templates
echo "静态服务器启动在: http://localhost:8000"
echo "按Ctrl+C停止服务器"
python3 -m http.server 8000
fi
fi