Spaces:
Build error
Build error
Fixed Mixed content (HTTPS)
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import flet.fastapi as flet_fastapi
|
|
| 5 |
import sys
|
| 6 |
import logging
|
| 7 |
import os
|
| 8 |
-
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
| 9 |
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
| 10 |
from collections import OrderedDict
|
| 11 |
import base64
|
|
@@ -127,8 +127,11 @@ app.mount("/flet-app", flet_fastapi.app(main))
|
|
| 127 |
UPLOAD_DIRECTORY = os.path.join(os.getcwd(), "uploaded_files")
|
| 128 |
|
| 129 |
@app.get("/", response_class=HTMLResponse)
|
| 130 |
-
async def serve_main_page():
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
<!DOCTYPE html>
|
| 133 |
<html lang="en">
|
| 134 |
<head>
|
|
@@ -136,24 +139,24 @@ async def serve_main_page():
|
|
| 136 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 137 |
<title>Audio Recorder App</title>
|
| 138 |
<style>
|
| 139 |
-
body, html {
|
| 140 |
margin: 0;
|
| 141 |
padding: 0;
|
| 142 |
height: 100%;
|
| 143 |
overflow: hidden;
|
| 144 |
-
}
|
| 145 |
-
#flet-app-frame {
|
| 146 |
width: 100%;
|
| 147 |
height: 100%;
|
| 148 |
border: none;
|
| 149 |
position: absolute;
|
| 150 |
top: 0;
|
| 151 |
left: 0;
|
| 152 |
-
}
|
| 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>
|
|
|
|
| 5 |
import sys
|
| 6 |
import logging
|
| 7 |
import os
|
| 8 |
+
from fastapi import FastAPI, File, UploadFile, HTTPException, Form, Request
|
| 9 |
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
| 10 |
from collections import OrderedDict
|
| 11 |
import base64
|
|
|
|
| 127 |
UPLOAD_DIRECTORY = os.path.join(os.getcwd(), "uploaded_files")
|
| 128 |
|
| 129 |
@app.get("/", response_class=HTMLResponse)
|
| 130 |
+
async def serve_main_page(request: Request):
|
| 131 |
+
# Get the base URL dynamically
|
| 132 |
+
base_url = str(request.base_url).rstrip('/')
|
| 133 |
+
|
| 134 |
+
html_content = f"""
|
| 135 |
<!DOCTYPE html>
|
| 136 |
<html lang="en">
|
| 137 |
<head>
|
|
|
|
| 139 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 140 |
<title>Audio Recorder App</title>
|
| 141 |
<style>
|
| 142 |
+
body, html {{
|
| 143 |
margin: 0;
|
| 144 |
padding: 0;
|
| 145 |
height: 100%;
|
| 146 |
overflow: hidden;
|
| 147 |
+
}}
|
| 148 |
+
#flet-app-frame {{
|
| 149 |
width: 100%;
|
| 150 |
height: 100%;
|
| 151 |
border: none;
|
| 152 |
position: absolute;
|
| 153 |
top: 0;
|
| 154 |
left: 0;
|
| 155 |
+
}}
|
| 156 |
</style>
|
| 157 |
</head>
|
| 158 |
<body>
|
| 159 |
+
<iframe id="flet-app-frame" src="{base_url}/flet-app"></iframe>
|
| 160 |
<iframe name="hidden-iframe" style="display:none;"></iframe>
|
| 161 |
</body>
|
| 162 |
</html>
|