在此先感谢您的帮助.我是python的新手,甚至更新的HTML.
过去几天我一直在尝试创建一个带有按钮的网页,以便在家庭服务器上执行任务.
目前我有一个python脚本生成一个带按钮的页面:
(See the simplified example below. removed code to clean up post)
Run Code Online (Sandbox Code Playgroud)
然后是一个python脚本,它运行所述命令并输出到iframe页面上:
(See the simplified example below. removed code to clean up post)
Run Code Online (Sandbox Code Playgroud)
这会在命令完成后输出整个完成的输出.我也尝试将-u选项添加到python脚本以运行它无缓冲.我也尝试过使用Python subprocess.如果它有助于我运行的命令类型apt-get update,以及其他用于移动文件和修复文件夹权限的Python脚本.
当从普通的Ubuntu服务器终端运行时它运行正常并实时输出,并且从我的研究中它应该在命令运行时输出.
谁能告诉我哪里出错了?我应该使用其他语言来执行此功能吗?
编辑简化示例:
初始页面:
#runcmd.html
<head>
<title>Admin Tasks</title>
</head>
<center>
<iframe src="/scripts/python/test/createbutton.py" width="650" height="800" frameborder="0" ALLOWTRANSPARENCY="true"></iframe>
<iframe width="650" height="800" frameborder="0" ALLOWTRANSPARENCY="true" name="display"></iframe>
</center>
Run Code Online (Sandbox Code Playgroud)
创建按钮的脚本:
cmd_page = '<form action="/scripts/python/test/runcmd.py" method="post" target="display" >' + '<label for="run_update">run updates</label><br>' + '<input align="Left" type="submit" value="runupdate" name="update" title="run_update">' + "</form><br>" …Run Code Online (Sandbox Code Playgroud)