-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bat
More file actions
119 lines (102 loc) · 3.05 KB
/
Copy pathsetup.bat
File metadata and controls
119 lines (102 loc) · 3.05 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@echo off
SETLOCAL EnableDelayedExpansion
REM --- Configuration ---
set "BACKEND_DIR=backend"
set "FRONTEND_DIR=frontend"
set "PYTHON_PATH=C:\Users\nanfo\AppData\Local\Programs\Python\Python310\python.exe"
set "NPM=npm"
set "BACKEND_PORT=5000"
set "API_URL=http://localhost:%BACKEND_PORT%"
set "LOG_FILE=setup.log"
echo Starting HueYou setup... > %LOG_FILE%
REM --- Verify Python Version ---
echo Checking Python version...
"%PYTHON_PATH%" --version > nul 2>&1
if %ERRORLEVEL% neq 0 (
echo ERROR: Python not found at %PYTHON_PATH%. Update PYTHON_PATH in setup.bat. >> %LOG_FILE%
echo ERROR: Python not found.
pause
exit /b 1
)
for /f "tokens=2 delims= " %%v in ('"%PYTHON_PATH%" --version') do set "PYTHON_VERSION=%%v"
echo Python version: %PYTHON_VERSION% >> %LOG_FILE%
echo Python version: %PYTHON_VERSION%
for /f "tokens=1,2 delims=." %%a in ("%PYTHON_VERSION%") do (
set "MAJOR=%%a"
set "MINOR=%%b"
)
if not "!MAJOR!.!MINOR!"=="3.10" (
echo ERROR: Stable Python 3.10 required, found %PYTHON_VERSION%. Update PYTHON_PATH in setup.bat. >> %LOG_FILE%
echo ERROR: Stable Python 3.10 required.
pause
exit /b 1
)
REM --- Setup Backend ---
echo Setting up backend...
if not exist "%BACKEND_DIR%" (
echo ERROR: Backend directory not found. >> %LOG_FILE%
echo ERROR: Backend directory not found.
pause
exit /b 1
)
cd /d "%BACKEND_DIR%"
if not exist venv (
echo Creating virtual environment...
"%PYTHON_PATH%" -m venv venv
)
call venv\Scripts\activate
echo Installing backend dependencies...
python -m pip install --upgrade pip
if exist requirements.txt (
pip install -r requirements.txt
) else (
pip install flask flask-cors pillow opencv-python numpy mediapipe reportlab filetype
)
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to install dependencies. Ensure Visual C++ Build Tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/. >> %LOG_FILE%
echo ERROR: Failed to install dependencies.
pause
exit /b 1
)
if not exist "main.py" (
echo ERROR: main.py not found. Rename app.py to main.py to avoid filter issues. >> %LOG_FILE%
echo ERROR: main.py not found.
dir *.py >> %LOG_FILE%
pause
exit /b 1
)
if not exist "hueyou_utils.py" (
echo ERROR: hueyou_utils.py not found. >> %LOG_FILE%
echo ERROR: hueyou_utils.py not found.
pause
exit /b 1
)
if not exist uploads (
mkdir uploads
)
echo Starting backend...
start cmd /k "call venv\Scripts\activate && python main.py"
REM --- Setup Frontend ---
cd /d "%~dp0"
cd /d "%FRONTEND_DIR%"
if %ERRORLEVEL% neq 0 (
echo ERROR: Frontend directory not found. >> %LOG_FILE%
echo ERROR: Frontend directory not found.
pause
exit /b 1
)
if not exist .env (
echo Creating .env file...
echo REACT_APP_API_URL=%API_URL% > .env
)
if not exist node_modules (
echo Installing frontend dependencies...
%NPM% install
)
echo Starting frontend...
start cmd /k "%NPM% start"
echo All set! Backend is running on %API_URL%
echo Frontend is running on http://localhost:3000
echo Check %LOG_FILE% for errors.
pause
ENDLOCAL