Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
from dotenv import load_dotenv | |
from generate import generate | |
load_dotenv() | |
password = os.environ['PASSWORD'] | |
async def run(initials, pdf_url, pdf_file): | |
if initials != password: | |
return 'κΆνμ΄ μμ΅λλ€.', '' | |
url = pdf_url or pdf_file | |
res = await generate(url) | |
return res | |
theme = gr.themes.Base() | |
def main(): | |
with gr.Blocks(theme=theme, title='PaperDeck') as demo: | |
gr.Markdown('# ') | |
with gr.Row(): | |
with gr.Column(scale=5): | |
gr.Markdown('# PaperDeck') | |
with gr.Row(): | |
with gr.Column(scale=1, min_width=300): | |
gr.Markdown('# ') | |
gr.Markdown('## μ λ‘λ') | |
with gr.Group(): | |
password_input = gr.Textbox(max_lines=1, placeholder='μ΄λμ μ μ λ ₯νμΈμ.', show_label=False) | |
url_input = gr.Textbox(max_lines=1, placeholder='λ Όλ¬Έμ URLμ μ λ ₯νμΈμ.', show_label=False) | |
pdf_file = gr.File(show_label=False) | |
submit_button = gr.Button(value='μ€ν', variant='primary') | |
with gr.Column(scale=3, min_width=600): | |
gr.Markdown('# ') | |
gr.Markdown('## κ²°κ³Ό') | |
with gr.Tab('Preview'): | |
preview_html = gr.HTML() | |
with gr.Tab('Beamer'): | |
beamer_markdown = gr.Markdown() | |
submit_button.click(fn=run, inputs=[password_input, url_input, pdf_file], outputs=[preview_html, beamer_markdown]) | |
demo.launch() | |
if __name__ == '__main__': | |
# launch gradio application | |
main() | |