seawolf2357 commited on
Commit
1cd16bc
โ€ข
1 Parent(s): 17bf8a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -14,13 +14,15 @@ def upload_file_to_hf_space(uploaded_file):
14
  space_name = "video" # ์ŠคํŽ˜์ด์Šค ์ด๋ฆ„์„ ์—ฌ๊ธฐ์— ์ž…๋ ฅํ•˜์„ธ์š”.
15
  repo_id = f"{user_id}/{space_name}"
16
 
17
- # ํŒŒ์ผ๋ช… ์„ค์ •
18
  file_path = uploaded_file.name
19
-
20
- # ํŒŒ์ผ ์ €์žฅ
21
  with open(file_path, "wb") as f:
22
  f.write(uploaded_file.read())
23
 
 
 
 
 
24
  # Hugging Face Spaces์— ํŒŒ์ผ ์—…๋กœ๋“œ
25
  response = api.upload_file(
26
  path_or_fileobj=file_path,
@@ -36,11 +38,7 @@ def upload_file_to_hf_space(uploaded_file):
36
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
37
  iface = gr.Interface(
38
  fn=upload_file_to_hf_space,
39
- inputs=gr.File(filetypes=["mp4"], label="Upload your MP4 file"),
40
  outputs="text",
41
  title="MP4 File Upload to Hugging Face Spaces",
42
- description="Upload an MP4 file and get its URL in Hugging Face Spaces."
43
- )
44
-
45
- # ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
46
- iface.launch()
 
14
  space_name = "video" # ์ŠคํŽ˜์ด์Šค ์ด๋ฆ„์„ ์—ฌ๊ธฐ์— ์ž…๋ ฅํ•˜์„ธ์š”.
15
  repo_id = f"{user_id}/{space_name}"
16
 
17
+ # ํŒŒ์ผ๋ช… ์„ค์ • ๋ฐ ์ €์žฅ
18
  file_path = uploaded_file.name
 
 
19
  with open(file_path, "wb") as f:
20
  f.write(uploaded_file.read())
21
 
22
+ # ํŒŒ์ผ ์œ ํ˜• ๊ฒ€์‚ฌ (MP4 ํŒŒ์ผ์ธ์ง€ ํ™•์ธ)
23
+ if not file_path.endswith('.mp4'):
24
+ return "Please upload an MP4 file."
25
+
26
  # Hugging Face Spaces์— ํŒŒ์ผ ์—…๋กœ๋“œ
27
  response = api.upload_file(
28
  path_or_fileobj=file_path,
 
38
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
39
  iface = gr.Interface(
40
  fn=upload_file_to_hf_space,
41
+ inputs=gr.File(label="Upload your MP4 file"),
42
  outputs="text",
43
  title="MP4 File Upload to Hugging Face Spaces",
44
+ description="Upload an MP4 file and