Danisz commited on
Commit
45b67fc
·
1 Parent(s): 7d94d26

Dynamic src through js

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -120,6 +120,7 @@ async def lifespan(app: FastAPI):
120
 
121
  app = FastAPI(lifespan=lifespan)
122
 
 
123
  app.mount("/flet-app", flet_fastapi.app(main))
124
 
125
 
@@ -153,8 +154,16 @@ async def serve_main_page(request: Request):
153
  </style>
154
  </head>
155
  <body>
156
- <iframe id="flet-app-frame" src="./flet-app"></iframe>
157
  <iframe name="hidden-iframe" style="display:none;"></iframe>
 
 
 
 
 
 
 
 
158
  </body>
159
  </html>
160
  """
 
120
 
121
  app = FastAPI(lifespan=lifespan)
122
 
123
+ # Make sure this line is correct and the path matches what you're using in the iframe src
124
  app.mount("/flet-app", flet_fastapi.app(main))
125
 
126
 
 
154
  </style>
155
  </head>
156
  <body>
157
+ <iframe id="flet-app-frame"></iframe>
158
  <iframe name="hidden-iframe" style="display:none;"></iframe>
159
+ <script>
160
+ window.onload = function() {
161
+ var iframe = document.getElementById('flet-app-frame');
162
+ var currentProtocol = window.location.protocol;
163
+ var currentHost = window.location.host;
164
+ iframe.src = currentProtocol + '//' + currentHost + '/flet-app';
165
+ };
166
+ </script>
167
  </body>
168
  </html>
169
  """