Files
simple/start.bat
T
catarrh 62c5b4e1a9 start: name the requested --http-host/--http-port in the opening line
The first line was hardcoded to http://127.0.0.1:8080 while the flags
were passed through, so ./start.sh --http-host 10.0.28.161 printed
127.0.0.1 although the server bound 10.0.28.161 (its own listening banner
named it).  Both start scripts now parse --http-host/--http-port (space
and = forms, the last value wins like argparse) and echo the effective
address; start.bat parses with shift (%* is unaffected, so the server
still receives every argument).

Bump 3.38.2 (server, pyproject, PWA header, sw simple-v483) and add the
CHANGELOG entry.

Tests: tests/test_pcsc_startup.py pins the parsing/echo (2 new).
1090 Python + 1075 frontend.
2026-10-25 03:25:22 +03:00

67 lines
2.5 KiB
Batchfile

@echo off
REM pysim-simple-server start script for Windows
REM Starts the server, preferring the venv if it exists.
REM PC/SC is built into Windows, so defaults to reader 0.
REM Every run is mirrored to simple_lastrun.log (overwritten on each start) with
REM PowerShell Tee-Object, so the latest server output can be read without
REM copy-pasting the console. The log contains card keys (test cards) and is
REM gitignored. (Windows PowerShell 5.1 writes it as UTF-16; PowerShell 7+ as
REM UTF-8.)
set VENV_DIR=%~dp0.venv
set LOG=%~dp0simple_lastrun.log
set PYTHONUNBUFFERED=1
REM The address the opening line names (v3.38.2). The server parses the same
REM flags; this mirrors its last-one-wins rule for the echo. %* is not
REM affected by SHIFT, so the server still receives every argument.
set "HTTP_HOST=127.0.0.1"
set "HTTP_PORT=8080"
:parse_http_args
if "%~1"=="" goto http_args_done
if /i "%~1"=="--http-host" (
set "HTTP_HOST=%~2"
shift
shift
goto parse_http_args
)
if /i "%~1"=="--http-port" (
set "HTTP_PORT=%~2"
shift
shift
goto parse_http_args
)
set "ARG=%~1"
if /i "%ARG:~0,12%"=="--http-host=" set "HTTP_HOST=%ARG:~12%"
if /i "%ARG:~0,12%"=="--http-port=" set "HTTP_PORT=%ARG:~12%"
shift
goto parse_http_args
:http_args_done
if exist "%VENV_DIR%\Scripts\pysim-simple-server.exe" (
echo Starting pysim-simple-server from venv on http://%HTTP_HOST%:%HTTP_PORT%
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
"%VENV_DIR%\Scripts\pysim-simple-server.exe" --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
if exist "%~dp0pysim_simple_server\__main__.py" (
echo Starting pysim-simple-server from source on http://%HTTP_HOST%:%HTTP_PORT%
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
python -m pysim_simple_server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
where pysim-simple-server >nul 2>&1
if %errorlevel% equ 0 (
echo Starting pysim-simple-server on http://%HTTP_HOST%:%HTTP_PORT%
echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop.
pysim-simple-server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'"
goto :eof
)
echo Error: pysim-simple-server not installed.
echo Run setup.bat first or install manually:
echo pip install pysim-simple-server
pause