Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| WEBHOOK_URL = "https://hook.make.com/YOUR_WEBHOOK_URL" | |
| def send_pdf(file): | |
| if file is None: | |
| return "β Please upload a PDF file." | |
| if not file.name.lower().endswith(".pdf"): | |
| return "β Only PDF files are allowed." | |
| try: | |
| with open(file.name, "rb") as f: | |
| response = requests.post( | |
| WEBHOOK_URL, | |
| files={"file": f}, | |
| timeout=20 | |
| ) | |
| if response.status_code != 200: | |
| return "β Upload failed. Webhook returned an error." | |
| return "β PDF sent successfully!" | |
| except Exception as e: | |
| return f"β Error sending file: {str(e)}" | |
| with gr.Blocks(title="PDF Upload") as demo: | |
| gr.Markdown( | |
| """ | |
| # π Upload PDF | |
| Select a PDF file and send it to the automation. | |
| """ | |
| ) | |
| pdf_input = gr.File( | |
| label="Choose PDF", | |
| file_types=[".pdf"], | |
| type="filepath" | |
| ) | |
| send_button = gr.Button("Send File") | |
| status_output = gr.Markdown() | |
| send_button.click( | |
| fn=send_pdf, | |
| inputs=pdf_input, | |
| outputs=status_output | |
| ) | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |