确保在与app.py相同的目录中有一个名为index.html的文件。如果index.html文件位于不同的目录中,可以在app.py中指定模板目录的路径。

在app.py中添加以下行: app = Flask(name, template_folder='path/to/templates') # 将'path/to/templates'替换为index.html文件所在的文件夹路径。

# apppyimport subprocessfrom flask import Flask render_template request jsonifyapp = Flask__name__process = Noneapproutedef index return render_templateindexhtmlapproutestart methods=POSTdef start