首页 > 解决方案 > R 闪亮 iframe 未连接到 HTTPS Flask 应用程序

问题描述

我正在尝试flaskR shiny iframe.

对于普通的 http 协议,这可以正常工作。但是,一旦我将其更改为 https 协议,它就无法连接,尽管我可以在浏览器中毫无问题地显示 https 烧瓶应用程序。在 iframe 中显示公共 https 网站也不是问题

我的烧瓶代码:

from flask import Flask, render_template

app = Flask(__name__)

@app.route("/data", methods=['GET', 'POST'])
def home():
    return render_template('index.html')

if __name__ == "__main__":
    app.run(debug=True, host='localhost', port=5000, ssl_context=('cert.pem', 'key.pem'))

我的 R 闪亮代码:

library(shiny)

ui <- fillPage(
    htmlOutput("frame")
)

server <- function(input, output) {
  output$frame <- renderUI({
    tags$iframe(src="https://localhost:5000/data", style='width:100vw;height:100vh;')
    # tags$iframe(src="https://www.bbc.co.uk/sport", style='width:100vw;height:100vh;')
  })
}

shinyApp(ui, server)

标签: rflaskiframehttpsshiny

解决方案


推荐阅读