amitness commited on
Commit
f4b1cfb
·
1 Parent(s): 61a80b4

Add the gradio app

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import shutil
3
+ import tarfile
4
+ import tempfile
5
+ import uuid
6
+
7
+ import gradio as gr
8
+ import requests
9
+
10
+
11
+ def convert_tar_to_zip(arxiv_url):
12
+ latex_source_url = (arxiv_url.replace('/abs/', '/e-print/')
13
+ .replace('arxiv.org', 'export.arxiv.org'))
14
+
15
+ # Fetch the latex source as .tar.gz file
16
+ tar_file = requests.get(latex_source_url).content
17
+ with tarfile.open(fileobj=io.BytesIO(tar_file)) as tar:
18
+ with tempfile.TemporaryDirectory() as dir:
19
+ # Extract the tar file to a temporary directory
20
+ tar.extractall(dir)
21
+
22
+ # Create a zip file from the extracted tar file
23
+ filename = str(uuid.uuid4())
24
+ zip_name = f'{filename}'
25
+ shutil.make_archive(filename, 'zip', dir)
26
+
27
+ return {'zip_url': f'{zip_name}.zip'}
28
+
29
+ inputs = gr.Textbox(label="URL")
30
+
31
+ title = "Conversion Engine for Arxiv Latex Tar to Zip"
32
+ description = "Enter the URL of the Arxiv paper"
33
+
34
+ gr.Interface(convert_tar_to_zip, inputs, "json", title=title, description=description).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests==2.26.0
2
+ gradio==3.25.0