psy3001 / app.py
osaaso's picture
Update app.py
9aec223 verified
Raw
History Blame Contribute Delete
703 Bytes
import os
import time
from huggingface_hub import HfApi
import gradio as gr
api = HfApi(token=os.environ["HF_TOKEN"])
def save_and_show(uploaded):
filename = os.path.basename(uploaded.name)
api.upload_file(
path_or_fileobj=uploaded.name,
path_in_repo=filename,
repo_id="osaaso/registrations",
repo_type="dataset"
)
time.sleep(1)
pdf_url = f"https://huggingface.co/datasets/osaaso/registrations/resolve/main/{filename}"
html = f"""
<iframe src="{pdf_url}" width="100%" height="800px"></iframe>
"""
return html
demo = gr.Interface(
fn=save_and_show,
inputs=gr.File(type="filepath"),
outputs=gr.HTML()
)
demo.launch()