Spaces:
Build error
Build error
add api prefix to routes
Browse files
app_init.py
CHANGED
@@ -29,7 +29,7 @@ def init_app(app: FastAPI, user_data: UserData, args: Args, pipeline):
|
|
29 |
allow_headers=["*"],
|
30 |
)
|
31 |
|
32 |
-
@app.websocket("/ws")
|
33 |
async def websocket_endpoint(websocket: WebSocket):
|
34 |
await websocket.accept()
|
35 |
user_count = user_data.get_user_count()
|
@@ -94,12 +94,12 @@ def init_app(app: FastAPI, user_data: UserData, args: Args, pipeline):
|
|
94 |
logging.error(f"Error: {e}")
|
95 |
traceback.print_exc()
|
96 |
|
97 |
-
@app.get("/
|
98 |
async def get_queue_size():
|
99 |
queue_size = user_data.get_user_count()
|
100 |
return JSONResponse({"queue_size": queue_size})
|
101 |
|
102 |
-
@app.get("/stream/{user_id}")
|
103 |
async def stream(user_id: uuid.UUID, request: Request):
|
104 |
try:
|
105 |
print(f"New stream request: {user_id}")
|
@@ -140,7 +140,7 @@ def init_app(app: FastAPI, user_data: UserData, args: Args, pipeline):
|
|
140 |
return HTTPException(status_code=404, detail="User not found")
|
141 |
|
142 |
# route to setup frontend
|
143 |
-
@app.get("/settings")
|
144 |
async def settings():
|
145 |
info_schema = pipeline.Info.schema()
|
146 |
info = pipeline.Info()
|
|
|
29 |
allow_headers=["*"],
|
30 |
)
|
31 |
|
32 |
+
@app.websocket("/api/ws")
|
33 |
async def websocket_endpoint(websocket: WebSocket):
|
34 |
await websocket.accept()
|
35 |
user_count = user_data.get_user_count()
|
|
|
94 |
logging.error(f"Error: {e}")
|
95 |
traceback.print_exc()
|
96 |
|
97 |
+
@app.get("/api/queue")
|
98 |
async def get_queue_size():
|
99 |
queue_size = user_data.get_user_count()
|
100 |
return JSONResponse({"queue_size": queue_size})
|
101 |
|
102 |
+
@app.get("/api/stream/{user_id}")
|
103 |
async def stream(user_id: uuid.UUID, request: Request):
|
104 |
try:
|
105 |
print(f"New stream request: {user_id}")
|
|
|
140 |
return HTTPException(status_code=404, detail="User not found")
|
141 |
|
142 |
# route to setup frontend
|
143 |
+
@app.get("/api/settings")
|
144 |
async def settings():
|
145 |
info_schema = pipeline.Info.schema()
|
146 |
info = pipeline.Info()
|
frontend/src/lib/components/ImagePlayer.svelte
CHANGED
@@ -26,7 +26,11 @@
|
|
26 |
>
|
27 |
<!-- svelte-ignore a11y-missing-attribute -->
|
28 |
{#if isLCMRunning}
|
29 |
-
<img
|
|
|
|
|
|
|
|
|
30 |
<div class="absolute bottom-1 right-1">
|
31 |
<Button
|
32 |
on:click={takeSnapshot}
|
|
|
26 |
>
|
27 |
<!-- svelte-ignore a11y-missing-attribute -->
|
28 |
{#if isLCMRunning}
|
29 |
+
<img
|
30 |
+
bind:this={imageEl}
|
31 |
+
class="aspect-square w-full rounded-lg"
|
32 |
+
src={'/api/stream/' + $streamId}
|
33 |
+
/>
|
34 |
<div class="absolute bottom-1 right-1">
|
35 |
<Button
|
36 |
on:click={takeSnapshot}
|
frontend/src/lib/lcmLive.ts
CHANGED
@@ -20,7 +20,7 @@ export const lcmLiveActions = {
|
|
20 |
|
21 |
try {
|
22 |
const websocketURL = `${window.location.protocol === "https:" ? "wss" : "ws"
|
23 |
-
}:${window.location.host}/ws`;
|
24 |
|
25 |
websocket = new WebSocket(websocketURL);
|
26 |
websocket.onopen = () => {
|
|
|
20 |
|
21 |
try {
|
22 |
const websocketURL = `${window.location.protocol === "https:" ? "wss" : "ws"
|
23 |
+
}:${window.location.host}/api/ws`;
|
24 |
|
25 |
websocket = new WebSocket(websocketURL);
|
26 |
websocket.onopen = () => {
|
frontend/src/routes/+page.svelte
CHANGED
@@ -24,11 +24,11 @@
|
|
24 |
});
|
25 |
|
26 |
async function getSettings() {
|
27 |
-
const settings = await fetch('/settings').then((r) => r.json());
|
28 |
pipelineParams = settings.input_params.properties;
|
29 |
pipelineInfo = settings.info.properties;
|
30 |
isImageMode = pipelineInfo.input_mode.default === PipelineMode.IMAGE;
|
31 |
-
maxQueueSize = settings.max_queue_size;
|
32 |
pageContent = settings.page_content;
|
33 |
console.log(pipelineParams);
|
34 |
toggleQueueChecker(true);
|
@@ -43,7 +43,7 @@
|
|
43 |
if (!queueCheckerRunning) {
|
44 |
return;
|
45 |
}
|
46 |
-
const data = await fetch('/
|
47 |
currentQueueSize = data.queue_size;
|
48 |
setTimeout(getQueueSize, 10000);
|
49 |
}
|
|
|
24 |
});
|
25 |
|
26 |
async function getSettings() {
|
27 |
+
const settings = await fetch('/api/settings').then((r) => r.json());
|
28 |
pipelineParams = settings.input_params.properties;
|
29 |
pipelineInfo = settings.info.properties;
|
30 |
isImageMode = pipelineInfo.input_mode.default === PipelineMode.IMAGE;
|
31 |
+
maxQueueSize = 2; //settings.max_queue_size;
|
32 |
pageContent = settings.page_content;
|
33 |
console.log(pipelineParams);
|
34 |
toggleQueueChecker(true);
|
|
|
43 |
if (!queueCheckerRunning) {
|
44 |
return;
|
45 |
}
|
46 |
+
const data = await fetch('/api/queue').then((r) => r.json());
|
47 |
currentQueueSize = data.queue_size;
|
48 |
setTimeout(getQueueSize, 10000);
|
49 |
}
|
frontend/vite.config.ts
CHANGED
@@ -5,8 +5,8 @@ export default defineConfig({
|
|
5 |
plugins: [sveltekit()],
|
6 |
server: {
|
7 |
proxy: {
|
8 |
-
'
|
9 |
-
'/ws': {
|
10 |
target: 'ws://localhost:7860',
|
11 |
ws: true
|
12 |
}
|
|
|
5 |
plugins: [sveltekit()],
|
6 |
server: {
|
7 |
proxy: {
|
8 |
+
'/api': 'http://localhost:7860',
|
9 |
+
'/api/ws': {
|
10 |
target: 'ws://localhost:7860',
|
11 |
ws: true
|
12 |
}
|