JPMadsen commited on
Commit
b0a935d
·
1 Parent(s): 9eb3bd4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import fitz
4
+
5
+ def merge(pdfs):
6
+
7
+ os.makedirs("out", exist_ok = True)
8
+ os.chir("./out")
9
+
10
+ result = fitz.open()
11
+
12
+ for pdf in pdfs:
13
+ with fitz.open(pdf) as mfile:
14
+ result.insert_pdf(mfile)
15
+
16
+ result.save("merge.pdf")
17
+
18
+ file = os.getcwd + "merge.pdf"
19
+
20
+ return file
21
+
22
+ demo = gr.Interface(
23
+ fn = merge,
24
+ inputs = gr.Files(file_types = ["text",".pdf"]),
25
+ outputs = "file",
26
+ theme = 'nuttea/Softblue',
27
+ allow_flagging = "never"
28
+ )
29
+
30
+ demo.queue(concurrency_count = 10)
31
+ demo.launch()