打开第一个终端:
# Windows
cd D:\work\baidu-autosave
python web_app.py
# Linux/Mac
cd /path/to/baidu-autosave
python web_app.py✅ 看到 Server started at http://0.0.0.0:5000 表示成功
打开第二个终端:
# Windows
cd D:\work\baidu-autosave\frontend
npm install
npm run dev
# Linux/Mac
cd /path/to/baidu-autosave/frontend
npm install
npm run dev✅ 看到 Local: http://localhost:3000/ 表示成功
# 项目根目录执行
cd D:\work\baidu-autosave
Start-Process powershell -ArgumentList "-Command", "python web_app.py"
Start-Sleep 3
cd frontend
if (!(Test-Path "node_modules")) { npm install }
npm run dev#!/bin/bash
cd /path/to/baidu-autosave
python web_app.py &
BACKEND_PID=$!
sleep 3
cd frontend
[ ! -d "node_modules" ] && npm install
npm run dev
# 停止后端:kill $BACKEND_PID如果已配置 Docker:
# 构建并启动
docker-compose up --build
# 后台运行
docker-compose up -d# Windows
netstat -an | findstr :5000
# Linux/Mac
lsof -i :5000
# 或
netstat -tlnp | grep :5000# Windows
netstat -an | findstr :3000
# Linux/Mac
lsof -i :3000
# 或
netstat -tlnp | grep :3000# 停止前端:Ctrl+C
# 停止后端:Ctrl+C
# 强制停止端口进程
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Linux/Mac
lsof -ti:5000 | xargs kill -9
lsof -ti:3000 | xargs kill -9# 后端日志
tail -f log/web_app_$(date +%Y-%m-%d).log
# 前端日志(开发服务器输出)
# 直接在启动终端查看# 重启后端:Ctrl+C 后重新运行 python web_app.py
# 重启前端:Ctrl+C 后重新运行 npm run dev 在 .bashrc 或 .profile 中添加:
# 后端启动
alias start-backend='cd /path/to/baidu-autosave && python web_app.py'
# 前端启动
alias start-frontend='cd /path/to/baidu-autosave/frontend && npm run dev'
# 一键启动
alias start-app='cd /path/to/baidu-autosave && python web_app.py & cd frontend && npm run dev'Windows PowerShell Profile ($PROFILE) 中添加:
function Start-Backend { cd D:\work\baidu-autosave; python web_app.py }
function Start-Frontend { cd D:\work\baidu-autosave\frontend; npm run dev }
function Start-App {
cd D:\work\baidu-autosave
Start-Process python -ArgumentList "web_app.py"
cd frontend
npm run dev
}- 开发时:使用两个终端窗口,方便查看各自日志
- 演示时:使用一键启动脚本
- 生产时:使用 Docker 或系统服务
启动后可通过局域网IP访问:
# 查看本机IP
# Windows
ipconfig
# Linux/Mac
ifconfig然后在手机浏览器访问:http://你的IP:3000