rogerxavier commited on
Commit
55045d8
1 Parent(s): cb43e30

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +18 -1
api.py CHANGED
@@ -132,7 +132,7 @@ def process_tasks_and_upload(file_list, bili_meta_data, cover_url,allow_submit,
132
 
133
  if allow_submit:
134
  #因为采用cover_url上传,所以不需要读取内容然后保存本地->这样也会引起协程问题
135
- print("开始对cover_url是",cover_url,"的提交进程进行加入后台任务")
136
  background_tasks.add_task(upload_video,bili_meta_data, cover_url)
137
  ##尝试能立刻返回的
138
 
@@ -203,3 +203,20 @@ async def get_cover_image():
203
  file_path = os.path.join(cover_dir, "0.jpg")
204
  return FileResponse(file_path)
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  if allow_submit:
134
  #因为采用cover_url上传,所以不需要读取内容然后保存本地->这样也会引起协程问题
135
+ print("bili的提交进程进行加入后台任务")
136
  background_tasks.add_task(upload_video,bili_meta_data, cover_url)
137
  ##尝试能立刻返回的
138
 
 
203
  file_path = os.path.join(cover_dir, "0.jpg")
204
  return FileResponse(file_path)
205
 
206
+
207
+
208
+ #测试能否在处理请求的时候请求另一个接口获取图片
209
+ @app.get("/coverTest.jpg")
210
+ def get_cover_image():
211
+ url = "https://rogerxavier-moviepy-with-manga-cover.hf.space/cover.jpg"
212
+ response = requests.get(url)
213
+ if response.status_code == 200:
214
+ with open("cover/0.jpg", "wb") as f:
215
+ f.write(response.content)
216
+ print("Cover image downloaded successfully.")
217
+ else:
218
+ print("Failed to download cover image. Status code:", response.status_code)
219
+ cover_dir = "cover"
220
+ file_path = os.path.join(cover_dir, "0.jpg")
221
+ return FileResponse(file_path)
222
+