Files
computer-network/QUICKSTART.md
T
2026-03-30 22:05:57 +08:00

123 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速开始指南
## 问题已解决 ✅
管理控制台的"需要完善逻辑"问题已修复!
## 立即使用
### 1. 启动服务器
```bash
./webserver.exe
```
### 2. 访问地址
- **主服务器**: http://localhost:9000
- **管理控制台**: http://localhost:9001
### 3. 管理控制台功能
#### 可用的按钮:
- **Refresh Status**: 刷新服务器运行状态
- **View All Logs**: 查看所有访问日志
- **Clear Logs**: 清空日志(可实际操作)
- **Refresh Logs**: 手动刷新日志显示
#### 实时显示:
- 服务器状态(Running/Stopped)
- 监听端口号(9000)
- 总请求数量
- 管理控制台端口(9001)
- 最近10条访问日志
## 测试示例
### 测试主服务器
```bash
# 正常页面
curl http://localhost:9000/ # 200 OK
curl http://localhost:9000/test.html # 200 OK
# 错误页面
curl http://localhost:9000/notfound.html # 404 Not Found
# 不支持的方法
curl -X POST http://localhost:9000/test # 501 Not Implemented
```
### 测试管理控制台
```bash
# 管理页面
curl http://localhost:9001/ # 200 OK
# API接口
curl http://localhost:9001/api/status # {"running":true,"port":9000}
curl http://localhost:9001/api/logs # 显示所有日志
# 清空日志
curl -X DELETE http://localhost:9001/api/logs
# 响应: {"message":"Logs cleared successfully","success":true}
```
## 功能验证清单
- [x] 主服务器正常启动(端口 9000)
- [x] 管理控制台正常启动(端口 9001)
- [x] 主页可以访问(200 OK)
- [x] 测试页面可以访问(200 OK)
- [x] 404页面正常显示(404 Not Found)
- [x] POST请求返回501错误
- [x] 管理控制台页面可以访问
- [x] 状态API返回正确信息
- [x] 日志API返回访问记录
- [x] 清空日志功能正常工作
## 常见问题
### Q1: 服务器启动失败?
**A**: 检查端口9000和9001是否被占用,修改config.json中的端口配置。
### Q2: 管理控制台无法访问?
**A**: 确认服务器已启动,访问 http://localhost:9001
### Q3: 日志无法清空?
**A**:
1. 确保访问的是管理控制台端口9001
2. 检查浏览器控制台是否有错误
3. 尝试刷新页面后再次点击
### Q4: 如何修改端口?
**A**: 编辑 config.json 文件:
```json
{
"port": 你的端口,
"admin_port": 你的管理端口,
"root_dir": "./web"
}
```
### Q5: 如何停止服务器?
**A**: 按 Ctrl+C 或关闭终端窗口
## 技术支持
如有问题,请查看以下文档:
- `README.md` - 完整项目说明
- `USAGE.md` - 详细使用指南
- `UPDATE_NOTES.md` - 功能更新说明
- `FIX_REPORT.md` - 问题修复报告
## 项目特色
✅ **多线程并发** - goroutine 处理并发请求
✅ **完整HTTP实现** - 手动解析和构造HTTP报文
✅ **Web管理界面** - 图形化控制台
✅ **实时日志** - 控制台 + Web 双重显示
✅ **在线管理** - 可清空日志、查看状态
✅ **零依赖** - 仅使用Go标准库
---
**项目状态**: ✅ 功能完善,可正常使用
**更新日期**: 2026年3月30日