CoolFace
Datasetpublic

echodict/ppv5

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes220downloads
run_https.ps159 linesDownload Raw Back to root
1$ErrorActionPreference = "Stop"2 3$root = $PSScriptRoot4if (-not $root) { $root = (Get-Location).Path }5 6$toolsDir = Join-Path $root "tools"7$certsDir = Join-Path $root "certs"8 9New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null10New-Item -ItemType Directory -Force -Path $certsDir | Out-Null11 12$mkcert = Get-Command mkcert -ErrorAction SilentlyContinue13$mkcertPath = $null14if ($mkcert) {15  $mkcertPath = $mkcert.Source16} else {17  $mkcertPath = Join-Path $toolsDir "mkcert.exe"18  if (-not (Test-Path $mkcertPath)) {19    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls1220    $rel = Invoke-RestMethod -Uri "https://api.github.com/repos/FiloSottile/mkcert/releases/latest"21    $asset = $rel.assets | Where-Object { $_.name -eq "mkcert-v$($rel.tag_name.TrimStart('v'))-windows-amd64.exe" } | Select-Object -First 122    if (-not $asset) {23      $asset = $rel.assets | Where-Object { $_.name -match "windows-amd64\.exe$" } | Select-Object -First 124    }25    if (-not $asset) {26      throw "无法从 GitHub release 自动定位 mkcert 的 windows-amd64.exe"27    }28    Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $mkcertPath -UseBasicParsing29  }30}31 32& $mkcertPath -install | Out-Host33 34$certFile = Join-Path $certsDir "localhost.pem"35$keyFile = Join-Path $certsDir "localhost-key.pem"36& $mkcertPath -key-file $keyFile -cert-file $certFile "localhost" "127.0.0.1" "::1" | Out-Host37 38$pythonCandidates = @(39  (Join-Path $root ".venv\Scripts\python.exe"),40  (Join-Path $root ".venv_cpu\Scripts\python.exe")41)42$pythonPath = $pythonCandidates | Where-Object { Test-Path $_ } | Select-Object -First 143if (-not $pythonPath) {44  $py = Get-Command python -ErrorAction SilentlyContinue45  if ($py) { $pythonPath = $py.Source }46}47if (-not $pythonPath) {48  throw "找不到 python。请先创建 venv(.venv 或 .venv_cpu)或确保 python 在 PATH 里。"49}50 51$env:PPV5_USE_HTTPS = "1"52$env:PPV5_HOST = "127.0.0.1"53$env:PPV5_PORT = "9346"54$env:PPV5_TLS_CERT = $certFile55$env:PPV5_TLS_KEY = $keyFile56 57Set-Location $root58& $pythonPath (Join-Path $root "main_v6.py")59