coollsd commited on
Commit
db6de85
1 Parent(s): 7a55581

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -3,6 +3,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, StreamingResponse
3
  import aiohttp
4
  import asyncio
5
  from typing import Dict
 
6
 
7
  app = FastAPI()
8
 
@@ -434,7 +435,7 @@ HTML_CONTENT = """
434
  overflow: auto;
435
  }
436
 
437
- .quick-open-content {
438
  margin: 5% auto;
439
  padding: 20px;
440
  width: 90%;
@@ -846,7 +847,7 @@ HTML_CONTENT = """
846
  };
847
  actionsContainer.appendChild(quickOpenBtn);
848
 
849
- if (item.fileName.toLowerCase().endsWith('.mp4')) {
850
  const embedBtn = document.createElement('button');
851
  embedBtn.textContent = 'Embed';
852
  embedBtn.className = 'small-btn';
@@ -863,7 +864,7 @@ HTML_CONTENT = """
863
  historyModal.style.display = "block";
864
  }
865
 
866
- function quickOpen(url, fileName) {
867
  quickOpenContent.innerHTML = '';
868
  const fullUrl = window.location.origin + url;
869
 
@@ -908,7 +909,6 @@ HTML_CONTENT = """
908
  </body>
909
  </html>
910
  """
911
-
912
  @app.get("/", response_class=HTMLResponse)
913
  async def index():
914
  return HTML_CONTENT
@@ -951,7 +951,7 @@ async def handle_video_stream(path: str, request: Request):
951
  if response.status == 206:
952
  headers['Content-Range'] = response.headers.get('Content-Range')
953
 
954
- return StreamingResponse(content, status_code=response.status, headers=headers)
955
 
956
  @app.get("/embed")
957
  async def embed_video(url: str, thumbnail: str):
@@ -1050,7 +1050,6 @@ async def chunked_upload(upload_url: str, file: UploadFile, content_type: str, c
1050
  return True
1051
 
1052
  async def get_file_size(file: UploadFile) -> int:
1053
- await file.seek(0)
1054
  size = 0
1055
  while chunk := await file.read(8192):
1056
  size += len(chunk)
 
3
  import aiohttp
4
  import asyncio
5
  from typing import Dict
6
+ import io
7
 
8
  app = FastAPI()
9
 
 
435
  overflow: auto;
436
  }
437
 
438
+ .quick-open-content {
439
  margin: 5% auto;
440
  padding: 20px;
441
  width: 90%;
 
847
  };
848
  actionsContainer.appendChild(quickOpenBtn);
849
 
850
+ if (item.fileName.toLowerCase().endsWith('.mp4')) {
851
  const embedBtn = document.createElement('button');
852
  embedBtn.textContent = 'Embed';
853
  embedBtn.className = 'small-btn';
 
864
  historyModal.style.display = "block";
865
  }
866
 
867
+ function quickOpen(url, fileName) {
868
  quickOpenContent.innerHTML = '';
869
  const fullUrl = window.location.origin + url;
870
 
 
909
  </body>
910
  </html>
911
  """
 
912
  @app.get("/", response_class=HTMLResponse)
913
  async def index():
914
  return HTML_CONTENT
 
951
  if response.status == 206:
952
  headers['Content-Range'] = response.headers.get('Content-Range')
953
 
954
+ return StreamingResponse(io.BytesIO(content), status_code=response.status, headers=headers)
955
 
956
  @app.get("/embed")
957
  async def embed_video(url: str, thumbnail: str):
 
1050
  return True
1051
 
1052
  async def get_file_size(file: UploadFile) -> int:
 
1053
  size = 0
1054
  while chunk := await file.read(8192):
1055
  size += len(chunk)