我需要在我的 Django 应用程序中使用一个 HTML 网页来加载并在可滚动框中显示脚本的连续输出。这可能吗?
我目前正在使用子进程来运行 Python 脚本,但 HTML 页面在脚本完成后才会加载(这可能需要大约 5 分钟)。我希望用户看到正在发生的事情,而不仅仅是一个旋转的圆圈。
我已经用文本中的“\n”卸载了脚本的完整输出;如果可能,我希望它输出每个新行。
我的代码如下:
视图.py:
def projectprogress(request):
GenerateProjectConfig(request)
home = os.getcwd()
project_id = request.session['projectname']
staging_folder = home + "/staging/" + project_id + "/"
output = ""
os.chdir(staging_folder)
script = home + '/webscripts/terraformdeploy.py'
try:
output = subprocess.check_output(['python', script], shell=True)
except subprocess.CalledProcessError:
exit_code, error_msg = output.returncode, output.output
os.chdir(home)
return render(request, 'projectprogress.html', locals())
Run Code Online (Sandbox Code Playgroud)
项目进度.html:
<style>
div.ex1 {
background-color: black;
width: 900px;
height: 500px;
overflow: scroll;
margin: 50px;
}
</style> …
Run Code Online (Sandbox Code Playgroud) 有没有其他人得到以上信息?
我一生都无法弄清楚为什么它抱怨 google.api.core 模块。这上周对我有用,但自从更新了 google-api-python-client 之后,现在就不行了,我正在努力恢复到工作版本。
根据要求冻结点数:
asgiref==3.2.7
astroid==2.3.3
cachetools==3.1.1
certifi==2019.11.28
chardet==3.0.4
Click==7.0
colorama==0.4.1
Django==3.0.6
django-crispy-forms==1.9.0
django-formtools==2.2
Flask==1.1.1
google-api-core==1.21.0
google-api-python-client==1.9.3
google-auth==1.18.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
google-cloud==0.34.0
google-cloud-core==1.1.0
google-cloud-error-reporting==0.33.0
google-cloud-firestore==1.6.2
google-cloud-kms==1.3.0
google-cloud-logging==1.14.0
google-cloud-pubsub==1.1.0
google-cloud-secret-manager==0.2.0
googleapis-common-protos==1.6.0
grpc-google-iam-v1==0.12.3
grpcio==1.27.2
httplib2==0.14.0
idna==2.8
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.10.3
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
oauth2client==4.1.3
oauthlib==3.1.0
protobuf==3.12.2
pyasn1==0.4.8
pyasn1-modules==0.2.7
PyJWT==1.7.1
pylint==2.4.4
pytz==2019.3
PyYAML==5.3.1
requests==2.22.0
requests-oauthlib==1.3.0
rsa==4.0
six==1.13.0
sqlparse==0.3.1
twilio==6.35.5
uritemplate==3.0.0
urllib3==1.25.7
Werkzeug==0.16.0
wrapt==1.11.2
Run Code Online (Sandbox Code Playgroud)