forked from lza6/perplexity-2api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·70 lines (56 loc) · 1.56 KB
/
start.sh
File metadata and controls
executable file
·70 lines (56 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
echo "========================================"
echo " Perplexity-2API Local Python Launcher"
echo "========================================"
echo
# Exit immediately on error
set -e
# ---- Check Python ----
if ! command -v python3 >/dev/null 2>&1; then
echo "[ERROR] Python not found. Please install Python 3.8+"
exit 1
fi
echo "[INFO] Python version:"
python3 --version
echo
# ---- Check requirements.txt ----
if [ ! -f "requirements.txt" ]; then
echo "[ERROR] requirements.txt not found"
exit 1
fi
# ---- Check dependencies ----
echo "[INFO] Checking dependencies..."
if ! python3 - <<EOF >/dev/null 2>&1
import botasaurus, fastapi, uvicorn, httpx
EOF
then
echo "[INFO] Installing dependencies..."
pip3 install -r requirements.txt || {
echo "[ERROR] Failed to install dependencies"
exit 1
}
echo "[SUCCESS] Dependencies installed"
fi
# ---- Start service ----
echo
echo "[INFO] Starting service..."
echo "[INFO] Access URL: http://127.0.0.1:8092"
echo "[INFO] Press Ctrl+C to stop"
echo
# Start uvicorn in background
uvicorn main:app --host 127.0.0.1 --port 8092 --reload --no-access-log &
UVICORN_PID=$!
# Give server time to start
sleep 3
# Open browser (cross-platform)
if command -v xdg-open >/dev/null 2>&1; then
xdg-open http://127.0.0.1:8092
elif command -v open >/dev/null 2>&1; then
open http://127.0.0.1:8092
else
echo "[INFO] Open http://127.0.0.1:8092 manually"
fi
echo "[INFO] Browser opened. Service is running in background."
echo "[INFO] Press Ctrl+C to stop service."
# Wait for uvicorn process
wait $UVICORN_PID