File size: 637 Bytes
17b3fee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from pathlib import Path
import time
from flask import Flask, render_template
from update_predictions import load_model, main_task

app = Flask(__name__)
Config = {
    "REPO_PATH": Path(__file__).parent.resolve(),
    "MODEL_PATH": os.path.join(os.environ.get("SPACE_CACHE_DIR", "."), "Kronos_model"),
    # 其他配置保持不变...
}

# 加载模型(全局一次)
predictor = load_model()

@app.route("/")
def index():
    # 每次访问时更新预测(或定时更新,见下文)
    main_task(predictor)
    return render_template("index.html")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=7860)