from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
from flask import Flask, render_template, jsonify
import random


app = Flask(__name__)
 
# 假设的数据源，这里用随机数模拟实时更新的数据
data_source = [random.randint(0, 100) for _ in range(10)]
 
@app.route('/')
def index():
    return render_template('index.html')
 
@app.route('/data')
def data():
    # 返回最新数据
    return jsonify(data_source)
 
if __name__ == '__main__':
    app.run(debug=True)