Spaces:
Runtime error
Runtime error
Update api.py
Browse files
api.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
from typing import Union
|
3 |
|
4 |
from fastapi import FastAPI, WebSocket
|
5 |
from epub2txt import epub2txt
|
@@ -12,11 +11,10 @@ prompt = os.getenv("prompt")
|
|
12 |
app = FastAPI()
|
13 |
|
14 |
|
15 |
-
@app.websocket("/
|
16 |
-
async def read_root(
|
17 |
-
websocket: WebSocket,
|
18 |
-
f_name: str):
|
19 |
await websocket.accept()
|
|
|
20 |
ch_list = epub2txt(f_name, outputlist=True)
|
21 |
chapter_titles = epub2txt.content_titles
|
22 |
title = epub2txt.title
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
from fastapi import FastAPI, WebSocket
|
4 |
from epub2txt import epub2txt
|
|
|
11 |
app = FastAPI()
|
12 |
|
13 |
|
14 |
+
@app.websocket("/ws")
|
15 |
+
async def read_root(websocket: WebSocket):
|
|
|
|
|
16 |
await websocket.accept()
|
17 |
+
f_name = await websocket.receive_text()
|
18 |
ch_list = epub2txt(f_name, outputlist=True)
|
19 |
chapter_titles = epub2txt.content_titles
|
20 |
title = epub2txt.title
|