【发布时间】:2019-04-23 16:45:56
【问题描述】:
我试图通过 Flask 执行 Python 脚本。
我在下面写了python代码来执行另一个python脚本。
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("/home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
#return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
但不幸的是,当我在 python 代码上运行并检查 127.0.0.1:5000 它在浏览器中给出了这个错误:
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
有什么办法吗?
我的最终目标是通过 HTML 页面的 Button 打开一个 Python 脚本。
【问题讨论】: