Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from uuid import uuid4
|
4 |
+
|
5 |
+
def upload_file(file):
|
6 |
+
file_path = f"/tmp/{uuid4()}-{file.name}"
|
7 |
+
with open(file_path, "wb") as f:
|
8 |
+
f.write(file.read())
|
9 |
+
download_url = f"https://huggingface.co/space-name/download?file={file_path}"
|
10 |
+
return download_url
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=upload_file,
|
14 |
+
inputs="file",
|
15 |
+
outputs="text",
|
16 |
+
title="File Upload and Download URL Generator",
|
17 |
+
description="Upload a file and get a downloadable URL."
|
18 |
+
)
|
19 |
+
|
20 |
+
iface.launch()
|