feat: Python 参考实现(server.py)

- 零依赖 HTTP 服务器 + SQLite 存储

- 与 Go 版功能等价的历史/参考实现

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-08-23 21:29:55 +08:00
parent f207a0d0bd
commit 532d117415
4 changed files with 686 additions and 0 deletions

63
static/index.html Normal file
View File

@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>宿舍电费监控</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<div class="container">
<header>
<h1>⚡ 宿舍电费监控</h1>
<div class="room-info" id="roomInfo">加载中...</div>
</header>
<section class="card current-card">
<div class="card-header">
<span class="label">当前剩余电量</span>
<span class="status-badge" id="statusBadge">--</span>
</div>
<div class="surplus-display">
<span class="surplus-value" id="surplusValue">--</span>
<span class="surplus-unit"></span>
</div>
<div class="sub-info">
<span>预估金额: ¥<span id="amountValue">--</span></span>
<span>更新于: <span id="updateTime">--</span></span>
</div>
<button id="refreshBtn" class="refresh-btn">🔄 立即刷新</button>
</section>
<section class="card">
<div class="card-header">
<span class="label">近 7 天耗电量</span>
</div>
<canvas id="usageChart" height="220"></canvas>
<div class="chart-empty" id="chartEmpty">暂无历史数据</div>
</section>
<section class="card">
<div class="card-header">
<span class="label">每日电费记录</span>
</div>
<table class="history-table">
<thead>
<tr>
<th>日期</th>
<th>剩余电量(度)</th>
<th>日耗电(度)</th>
<th>记录方式</th>
</tr>
</thead>
<tbody id="historyBody">
<tr><td colspan="4" class="empty-td">加载中...</td></tr>
</tbody>
</table>
</section>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<script src="/static/app.js"></script>
</body>
</html>