Spaces:
Sleeping
Sleeping
updated
Browse files- main.py +2 -0
- {templates → static}/i.jpg +0 -0
- templates/index.html +3 -3
main.py
CHANGED
@@ -19,6 +19,8 @@ logger = logging.getLogger(__name__)
|
|
19 |
|
20 |
app = FastAPI()
|
21 |
|
|
|
|
|
22 |
@app.get("/", response_class=HTMLResponse)
|
23 |
async def get(request: Request):
|
24 |
logger.info("Serving the index page")
|
|
|
19 |
|
20 |
app = FastAPI()
|
21 |
|
22 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
23 |
+
|
24 |
@app.get("/", response_class=HTMLResponse)
|
25 |
async def get(request: Request):
|
26 |
logger.info("Serving the index page")
|
{templates → static}/i.jpg
RENAMED
File without changes
|
templates/index.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
<style>
|
8 |
body {
|
9 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
10 |
-
background: url('/
|
11 |
background-size: cover;
|
12 |
color: #f0f0f0;
|
13 |
display: flex;
|
@@ -110,7 +110,7 @@
|
|
110 |
}
|
111 |
};
|
112 |
|
113 |
-
const response = await fetch(
|
114 |
method: 'POST',
|
115 |
});
|
116 |
|
@@ -121,7 +121,7 @@
|
|
121 |
const result = await response.json();
|
122 |
logMessage(`Detection started: ${result.status}`, 'info');
|
123 |
|
124 |
-
websocket = new WebSocket(`
|
125 |
websocket.onmessage = function(event) {
|
126 |
const data = event.data;
|
127 |
logMessage(`Detected ${data} audio`, data);
|
|
|
7 |
<style>
|
8 |
body {
|
9 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
10 |
+
background: url('/static/i.jpg') no-repeat center center fixed;
|
11 |
background-size: cover;
|
12 |
color: #f0f0f0;
|
13 |
display: flex;
|
|
|
110 |
}
|
111 |
};
|
112 |
|
113 |
+
const response = await fetch(`${window.location.origin}/start_detection`, {
|
114 |
method: 'POST',
|
115 |
});
|
116 |
|
|
|
121 |
const result = await response.json();
|
122 |
logMessage(`Detection started: ${result.status}`, 'info');
|
123 |
|
124 |
+
websocket = new WebSocket(`wss://${window.location.host}/ws`);
|
125 |
websocket.onmessage = function(event) {
|
126 |
const data = event.data;
|
127 |
logMessage(`Detected ${data} audio`, data);
|