Spaces:
Running
Running
| import os | |
| from pathlib import Path | |
| import time | |
| from flask import Flask, render_template | |
| from update_predictions import load_local_model as load_model, main_task | |
| app = Flask(__name__) | |
| Config = { | |
| "REPO_PATH": Path(__file__).parent.resolve(), | |
| "MODEL_PATH": os.path.join("/tmp", "Kronos_model"), # 其他配置保持不变... | |
| } | |
| # 加载模型(全局一次) | |
| predictor = load_model() | |
| def index(): | |
| # 每次访问时更新预测(或定时更新,见下文) | |
| main_task(predictor) | |
| return render_template("index.html") | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) |