【问题标题】:Flask application redirects to empty "about:srcdoc" page when index (root path) is requested请求索引(根路径)时,Flask 应用程序重定向到空的“about:srcdoc”页面
【发布时间】:2019-10-25 22:09:54
【问题描述】:

我正在开发一个 Flask Web 应用程序。它有两个并排的 iframe 并访问一个 csv 文件。该文件包含通过使用 selenium .page_source() 将使用 srcdoc 加载到 iframe 中的 url。页面源是用beautiful soup 4 编辑的,然后变成字符串发送到前端。

我现在面临的问题是,当我打开应用程序(本地或虚拟机上托管的版本)时,有时我会被重定向到 url 栏中带有“about:srcdoc”的空白页面。虽然它不会 100% 发生,但它发生的频率足以成为一个问题。

GitHub 代码库:https://github.com/MohamedMoustafaNUIG/AnnotatorVM

flask 应用程序是 annotator.py,从根加载的页面是 app/templates/index.html 和 app/templates/base.html

index.html 中的代码 sn-p

<div class="row" style="width: 100%; height: 80%; min-height: 600px;">
    <p align="center">Annotated Origins: {{fpo}} / {{tpo}} for this page and {{fto}} / {{tto}} in total</p>
    <div class="column left" style="width:50%; position: relative; display: inline-block; margin: 0; border: 0; padding: 0;">
        <h4><a id="cLink" href="{{t3}}" target="_blank">Fact Checking Article: </a></h4>
      <iframe id="cframe" style="display: block" width="100%" height="100%" srcdoc="{{t1}}"></iframe>
    </div>
    <div class="column right" style="width:50%; position: relative; display: inline-block; margin: 0; border: 0; padding:0;">
      <h4><a id="oLink" href={{t4}} target="_blank">Origin Candidate: </a></h4>
      <iframe id="oframe" style="display: block" width="100%" height="100%" srcdoc="{{t2}}"></iframe>
    </div>
</div>

以前有没有人遇到过类似的问题?使用flask时不需要,我只是想了解重定向到“about:srcdoc”背后的逻辑。有什么建议吗?提前谢谢你:)

编辑:什么都没有?我不能成为第一个遇到这个问题的人。

【问题讨论】:

    标签: javascript python html flask iframe


    【解决方案1】:

    似乎某些页面显示在 iframe 中,其中将父页面(我的应用程序)重定向到 about:srcdoc url。通过对两个 iframe 进行沙盒处理并仅限制顶部导航解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 2021-07-05
      • 1970-01-01
      • 1970-01-01
      • 2020-08-11
      • 1970-01-01
      相关资源
      最近更新 更多