Spaces:
Runtime error
Runtime error
File size: 582 Bytes
16db73f 27abc69 16db73f 27abc69 16db73f 27abc69 16db73f 27abc69 16db73f 27abc69 16db73f 27abc69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
import os
UPLOAD_FOLDER = 'uploads'
if not os.path.exists(UPLOAD_FOLDER):
os.mkdir(UPLOAD_FOLDER)
def save_file(upload_file):
file_path = os.path.join(UPLOAD_FOLDER, upload_file.name)
with open(file_path, 'wb') as f:
f.write(upload_file.read())
return "File saved successfully!"
def upload_and_save_file(upload_file):
return save_file(upload_file)
inputs = gr.inputs.File(label="Upload a file")
outputs = gr.outputs.Textbox(label="Status")
gr.Interface(upload_and_save_file, inputs, outputs, title="Document Uploader").launch()
|