Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import tempfile
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
UPLOAD_URL = "https://0x0.st"
|
| 7 |
+
|
| 8 |
+
def upload_test(file):
|
| 9 |
+
if file is None:
|
| 10 |
+
return "No file uploaded"
|
| 11 |
+
|
| 12 |
+
filename = os.path.basename(file.name)
|
| 13 |
+
try:
|
| 14 |
+
with open(file.name, "rb") as f:
|
| 15 |
+
r = requests.post(UPLOAD_URL, files={"file": (filename, f)}, timeout=180)
|
| 16 |
+
r.raise_for_status()
|
| 17 |
+
url = r.text.strip()
|
| 18 |
+
return f"Uploaded successfully!\n\nFile: {filename}\nURL: {url}"
|
| 19 |
+
except Exception as e:
|
| 20 |
+
return f"Upload failed: {str(e)}"
|
| 21 |
+
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=upload_test,
|
| 24 |
+
inputs=gr.File(label="Upload a video file (any size, up to ~512MB)"),
|
| 25 |
+
outputs=gr.Textbox(label="Result"),
|
| 26 |
+
title="0x0.st Upload Test",
|
| 27 |
+
description="Test uploading to 0x0.st directly. Use a small video first."
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
iface.launch()
|