bluenevus commited on
Commit
bc4b939
·
verified ·
1 Parent(s): 728b915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -57,4 +57,28 @@ def compress_pdf(input_file, url, strength):
57
  except Exception as e:
58
  return None, f"Error compressing PDF: {str(e)}"
59
 
60
- # The rest of the code remains the same
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  except Exception as e:
58
  return None, f"Error compressing PDF: {str(e)}"
59
 
60
+ def process_and_compress(input_file, url, strength):
61
+ output_file, message = compress_pdf(input_file, url, strength)
62
+ if output_file:
63
+ return output_file, message
64
+ else:
65
+ return None, message
66
+
67
+ with gr.Blocks() as demo:
68
+ gr.Markdown("# PDF Compressor")
69
+ with gr.Row():
70
+ input_file = gr.File(label="Upload PDF")
71
+ url_input = gr.Textbox(label="Or enter PDF URL")
72
+ strength = gr.Radio(["Low", "Medium", "High"], label="Compression Strength", value="Medium", info="Low: Minimal compression, Medium: Moderate compression, High: Maximum compression")
73
+ compress_btn = gr.Button("Compress")
74
+ output_file = gr.File(label="Download Compressed PDF")
75
+ message = gr.Textbox(label="Message")
76
+
77
+ compress_btn.click(
78
+ process_and_compress,
79
+ inputs=[input_file, url_input, strength],
80
+ outputs=[output_file, message]
81
+ )
82
+
83
+ if __name__ == "__main__":
84
+ demo.launch(share=True)