上传 frontend 文件夹
This commit is contained in:
88
frontend/start_web.bat
Normal file
88
frontend/start_web.bat
Normal file
@@ -0,0 +1,88 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
title 微信公众号文章爬虫系统 - Web界面
|
||||
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo 🚀 微信公众号文章爬虫系统
|
||||
echo Web界面启动
|
||||
echo ===============================================
|
||||
echo.
|
||||
|
||||
:: 检查Python是否安装
|
||||
python --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo ❌ 未检测到Python,正在尝试其他方法...
|
||||
goto :use_powershell
|
||||
) else (
|
||||
echo ✅ 检测到Python环境
|
||||
goto :use_python
|
||||
)
|
||||
|
||||
:use_python
|
||||
echo 📱 使用Python启动Web服务器...
|
||||
echo 🌐 服务地址: http://localhost:8000
|
||||
echo ⏰ 启动时间: %date% %time%
|
||||
echo.
|
||||
echo 💡 提示: 按 Ctrl+C 停止服务器
|
||||
echo ===============================================
|
||||
echo.
|
||||
|
||||
cd /d "%~dp0"
|
||||
python -m http.server 8000
|
||||
goto :end
|
||||
|
||||
:use_powershell
|
||||
echo 📱 使用PowerShell启动Web服务器...
|
||||
echo 🌐 服务地址: http://localhost:8080
|
||||
echo ⏰ 启动时间: %date% %time%
|
||||
echo.
|
||||
echo 💡 提示: 按 Ctrl+C 停止服务器
|
||||
echo ===============================================
|
||||
echo.
|
||||
|
||||
cd /d "%~dp0"
|
||||
powershell -Command "
|
||||
$listener = New-Object System.Net.HttpListener
|
||||
$listener.Prefixes.Add('http://localhost:8080/')
|
||||
$listener.Start()
|
||||
Write-Host '✅ Web服务器已启动: http://localhost:8080'
|
||||
Write-Host '🌐 正在打开浏览器...'
|
||||
Start-Process 'http://localhost:8080'
|
||||
|
||||
while ($listener.IsListening) {
|
||||
$context = $listener.GetContext()
|
||||
$request = $context.Request
|
||||
$response = $context.Response
|
||||
|
||||
$path = $request.Url.LocalPath
|
||||
if ($path -eq '/') { $path = '/index.html' }
|
||||
|
||||
$filePath = Join-Path (Get-Location) $path.TrimStart('/')
|
||||
|
||||
if (Test-Path $filePath) {
|
||||
$content = [System.IO.File]::ReadAllBytes($filePath)
|
||||
$response.ContentType = switch ([System.IO.Path]::GetExtension($filePath).ToLower()) {
|
||||
'.html' { 'text/html; charset=utf-8' }
|
||||
'.css' { 'text/css; charset=utf-8' }
|
||||
'.js' { 'application/javascript; charset=utf-8' }
|
||||
'.json' { 'application/json; charset=utf-8' }
|
||||
default { 'text/plain; charset=utf-8' }
|
||||
}
|
||||
$response.ContentLength64 = $content.Length
|
||||
$response.OutputStream.Write($content, 0, $content.Length)
|
||||
} else {
|
||||
$response.StatusCode = 404
|
||||
$response.StatusDescription = 'Not Found'
|
||||
}
|
||||
|
||||
$response.OutputStream.Close()
|
||||
}
|
||||
"
|
||||
|
||||
:end
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo 服务器已停止运行
|
||||
echo ===============================================
|
||||
pause
|
||||
Reference in New Issue
Block a user