Add Flask/Python backend server
- Create app.py with Flask server on port 5002 - Add requirements.txt with Python dependencies - Add run_flask.bat for Windows users - Add run_flask.sh for Linux/Mac users - Complete Flask setup documentation - Database integration with PyMySQL - Full LLM API support (Gemini, DeepSeek, OpenAI, Claude) - CORS configuration - Error handling middleware Features: ✅ Runs on http://127.0.0.1:5002 ✅ All LLM APIs supported ✅ Database connection ✅ API proxy for CORS fix ✅ Auto setup scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
54
run_flask.sh
Normal file
54
run_flask.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Flask 伺服器啟動腳本
|
||||
|
||||
echo "========================================"
|
||||
echo "HR Performance System - Flask Server"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# 檢查 Python 是否安裝
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "[ERROR] Python 3 is not installed"
|
||||
echo "Please install Python 3.8 or higher"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 檢查虛擬環境
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "[INFO] Creating virtual environment..."
|
||||
python3 -m venv venv
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to create virtual environment"
|
||||
exit 1
|
||||
fi
|
||||
echo "[SUCCESS] Virtual environment created"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# 啟動虛擬環境
|
||||
echo "[INFO] Activating virtual environment..."
|
||||
source venv/bin/activate
|
||||
|
||||
# 安裝依賴
|
||||
echo "[INFO] Installing dependencies..."
|
||||
pip install -r requirements.txt
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to install dependencies"
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 檢查 .env 檔案
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "[WARNING] .env file not found"
|
||||
echo "Please create .env file with required configuration"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# 啟動 Flask 伺服器
|
||||
echo "[INFO] Starting Flask server..."
|
||||
echo "Server will run on http://127.0.0.1:5002"
|
||||
echo "Press Ctrl+C to stop the server"
|
||||
echo ""
|
||||
python3 app.py
|
||||
Reference in New Issue
Block a user