Mbonea commited on
Commit
f915194
·
1 Parent(s): c1500c2

made it to be a background task

Browse files
App/Shaders/ShaderRoutes.py CHANGED
@@ -1,7 +1,7 @@
1
- from fastapi import APIRouter, status
2
  from .Schemas import BaseRequest, BaseResponse
3
  from fastapi import FastAPI, HTTPException, Request
4
- import os
5
 
6
  # from HuggingChat import getChatBot
7
 
@@ -14,8 +14,10 @@ shader_router = APIRouter(tags=["Shaders"])
14
 
15
 
16
  @shader_router.get("/3d-effect")
17
- async def shader_3d(image_link: str):
18
- return make_effect(image_link=image_link)
 
 
19
 
20
 
21
  @shader_router.get("/shaderOuput/{audio_name}")
 
1
+ from fastapi import APIRouter, status, BackgroundTasks
2
  from .Schemas import BaseRequest, BaseResponse
3
  from fastapi import FastAPI, HTTPException, Request
4
+ import os, uuid
5
 
6
  # from HuggingChat import getChatBot
7
 
 
14
 
15
 
16
  @shader_router.get("/3d-effect")
17
+ async def shader_3d(image_link: str, background_task: BackgroundTasks):
18
+ filename = f"{str(uuid.uuid4())}.mp4"
19
+ background_task.add_task(make_effect, image_link=image_link, filename=filename)
20
+ return filename
21
 
22
 
23
  @shader_router.get("/shaderOuput/{audio_name}")
App/Shaders/utils.py CHANGED
@@ -10,8 +10,8 @@ import uuid
10
  depthflow = DepthFlowScene()
11
 
12
 
13
- def make_effect(image_link):
14
- filename = f"{str(uuid.uuid4())}.mp4"
15
  destination = os.path.join("/tmp/Video", filename)
16
  depthflow.input(image=image_link)
17
  depthflow.main(
 
10
  depthflow = DepthFlowScene()
11
 
12
 
13
+ def make_effect(image_link, filename: str):
14
+
15
  destination = os.path.join("/tmp/Video", filename)
16
  depthflow.input(image=image_link)
17
  depthflow.main(