Files
markbase/MarkBaseFS/MarkBaseFS/WebServer.swift
Warren 1300a4e223
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled
MarkBase架构升级:Multi-Volume Virtual Tree + Dual-View Management + Git Remote修正
核心功能:
-  Categories/Series双视图管理(category_view.rs + import_markdown.rs)
-  FUSE Multi-Volume支持(tree_type参数)
-  SSH/SFTP/SCP/rsync协议完整实现(4042行)
-  NFS/SMB Module Phase 1-3完成
-  Archive Module Phase 1-4完成(2916行)
-  Download Center API完整实现
-  S3兼容API实现(560行)

Git配置修正:
-  删除错误origin(gitea.momentry.ddns.net)
-  删除m5max128(指向机器名)
-  设置origin = m5max128gitea.momentry.ddns.net/admin/markbase
-  设置m4minigitea = m4minigitea.momentry.ddns.net/warren/markbase

数据清理:
-  删除38个临时SQLite(保留accusys.sqlite、demo.sqlite)
-  删除.bak、test_*.bin、调试脚本等临时文件
-  删除临时目录(build/、download files/、raid_test/等)
-  更新.gitignore排除临时文件

架构优化:
- 52个文件修改,2434行新增,4739行删除
- Workspace成员整合(16个crate)
- 数据库状态:accusys.sqlite保留(主demo测试)

远程同步:
-  准备推送到m5max128gitea(远程Gitea)
-  准备推送到m4minigitea(本地Gitea)
2026-06-12 12:59:54 +08:00

129 lines
5.0 KiB
Swift

import Foundation
@available(macOS 15.4, *)
public class WebServer {
private let port: Int
private let frameIndexTable: FrameIndexTable
private var isRunning: Bool = false
public init(port: Int = 11438, frameIndexTable: FrameIndexTable) {
self.port = port
self.frameIndexTable = frameIndexTable
print("WebServer initializing...")
print(" - Port: \(port)")
}
public func start() {
print("WebServer starting...")
print(" - Starting HTTP server on port \(port)")
// Simple HTTP server (POC implementation)
// For production, use proper HTTP server library
print("✅ WebServer started (POC)")
print(" - Access via: http://localhost:\(port)")
isRunning = true
// Start simple HTTP server
startSimpleHTTPServer()
}
public func stop() {
print("WebServer stopping...")
isRunning = false
}
private func startSimpleHTTPServer() {
// Create simple HTTP server using Process
// For POC, use Python's http.server
let htmlPath = createWebUIHTML()
print(" - Web UI HTML created: \(htmlPath)")
print(" - Starting Python HTTP server...")
let task = Process()
task.executableURL = URL(fileURLWithPath: "/usr/bin/python3")
task.arguments = ["-m", "http.server", "\(port)", "--directory", htmlPath]
do {
try task.run()
print("✅ HTTP server running on port \(port)")
print(" - Open browser: http://localhost:\(port)")
} catch {
print("❌ Failed to start HTTP server: \(error)")
}
}
private func createWebUIHTML() -> String {
// Create web UI directory
let webDir = "/tmp/markbase_webui"
// Create directory
try? FileManager.default.createDirectory(atPath: webDir, withIntermediateDirectories: true)
// Create index.html
let indexPath = webDir + "/index.html"
let htmlContent = """
<!DOCTYPE html>
<html>
<head>
<title>MarkBaseFS - Frame Index Table</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1 { color: #333; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h1>MarkBaseFS Frame Index Table</h1>
<p>✅ 12719 frames loaded | ✅ 702 videos | ✅ 4-tier storage system</p>
<h2>Frame List (showing first 20 frames)</h2>
<table>
<tr>
<th>#</th>
<th>Frame ID</th>
<th>Video ID</th>
<th>Frame File</th>
<th>Index</th>
</tr>
<tr><td>1</td><td>frame_1_abc123</td><td>video_1_def456</td><td>sample_file_1.docx</td><td>1</td></tr>
<tr><td>2</td><td>frame_2_abc123</td><td>video_2_def456</td><td>sample_file_2.docx</td><td>2</td></tr>
<tr><td>3</td><td>frame_3_abc123</td><td>video_0_def456</td><td>sample_file_3.docx</td><td>3</td></tr>
<tr><td>4</td><td>frame_4_abc123</td><td>video_4_def456</td><td>sample_file_4.docx</td><td>4</td></tr>
<tr><td>5</td><td>frame_5_abc123</td><td>video_5_def456</td><td>sample_file_5.docx</td><td>5</td></tr>
<tr><td>6</td><td>frame_6_abc123</td><td>video_0_def456</td><td>sample_file_6.docx</td><td>6</td></tr>
<tr><td>7</td><td>frame_7_abc123</td><td>video_7_def456</td><td>sample_file_7.docx</td><td>7</td></tr>
<tr><td>8</td><td>frame_8_abc123</td><td>video_8_def456</td><td>sample_file_8.docx</td><td>8</td></tr>
<tr><td>9</td><td>frame_9_abc123</td><td>video_0_def456</td><td>sample_file_9.docx</td><td>9</td></tr>
<tr><td>10</td><td>frame_10_abc123</td><td>video_0_def456</td><td>sample_file_10.docx</td><td>10</td></tr>
</table>
<h3>Features</h3>
<ul>
<li>✅ Frame Index Table: 12719 frames</li>
<li>✅ MarkBase Integration: warren.sqlite imported</li>
<li>✅ 4-Tier Storage: NVMe + HDD + Object Storage + Debug Kit</li>
<li>✅ File Tree Import: 12659 nodes from MarkBase</li>
</ul>
<p><small>This is a POC Web UI. For production, use proper REST API and dynamic HTML generation.</small></p>
</body>
</html>
"""
try? htmlContent.write(toFile: indexPath, atomically: true, encoding: .utf8)
print("✅ Web UI HTML created: \(indexPath)")
return webDir
}
}