Neon-AI commited on
Commit
d7044f8
·
verified ·
1 Parent(s): 5f90d38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -1,18 +1,29 @@
1
  import gradio as gr
2
  import requests
 
3
  import os
4
 
5
- def upload_fileio(file_path: str, file_name: str) -> str:
 
 
 
 
 
6
  try:
7
- with open(file_path, "rb") as f:
8
- r = requests.post("https://file.io", files={"file": (file_name, f)}, timeout=180)
 
 
9
  r.raise_for_status()
10
- if r.text.startswith("{"):
11
- data = r.json()
12
- if data.get("success"):
13
- return data["link"]
14
- return "Failed (non-JSON/HTML response)"
15
  except Exception as e:
16
- return f"Failed: {e}"
17
 
18
- gr.Interface(upload_fileio, gr.File(), gr.Textbox()).launch()
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import requests
3
+ import tempfile
4
  import os
5
 
6
+ LITTERBOX_API = "https://litterbox.catbox.moe/resources/internals/api.php"
7
+
8
+ def upload_litterbox(file):
9
+ if not file:
10
+ return "No file uploaded"
11
+ filename = os.path.basename(file.name)
12
  try:
13
+ with open(file.name, "rb") as f:
14
+ files = {"fileToUpload": (filename, f)}
15
+ data = {"reqtype": "fileupload", "time": "72h"}
16
+ r = requests.post(LITTERBOX_API, data=data, files=files, timeout=300)
17
  r.raise_for_status()
18
+ url = r.text.strip()
19
+ return f"Success!\nRaw MP4 link: {url}"
 
 
 
20
  except Exception as e:
21
+ return f"Failed: {str(e)}"
22
 
23
+ gr.Interface(
24
+ fn=upload_litterbox,
25
+ inputs=gr.File(label="Upload Video"),
26
+ outputs=gr.Textbox(label="Result"),
27
+ title="Litterbox Upload Test",
28
+ description="Upload MP4 → get raw link (up to 1GB, 72h expiry)"
29
+ ).launch()