workspace / app.py
raghuram13's picture
Update app.py
27abc69
raw
history blame contribute delete
582 Bytes
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()