Seetha commited on
Commit
d241351
1 Parent(s): d838831

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -45,19 +45,24 @@ import urllib # the lib that handles the url stuff
45
  from PyPDF2 import PdfReader
46
  text_list = []
47
 
48
- target_url = 'https://huggingface.co/datasets/Seetha/Visualization/raw/main/AFLAC_Wyatt_notag.pdf'
 
49
  if st.button('PDF1'):
50
- data = urllib.request.urlopen(target_url)
51
- for line in data.read():
52
- st.write(line)
53
- if data is not None:
54
- reader = PdfReader(data)
55
- for page in reader.pages:
56
- text = page.extract_text()
57
- text_list.append(text)
58
- st.write(text_list)
59
- else:
60
- st.error("Please upload your own PDF to be analyzed")
61
- st.stop()
 
 
 
 
62
  else:
63
  st.write('Goodbye')
 
45
  from PyPDF2 import PdfReader
46
  text_list = []
47
 
48
+ #target_url = 'https://huggingface.co/datasets/Seetha/Visualization/raw/main/AFLAC_Wyatt_notag.pdf'
49
+ file_path = "AFLAC_Wyatt_notag.pdf"
50
  if st.button('PDF1'):
51
+ with open(file_path,"rb") as f:
52
+ base64_pdf = base64.b64encode(f.read()).decode('utf-8')
53
+ pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf"></iframe>'
54
+ st.markdown(pdf_display, unsafe_allow_html=True)
55
+ # data = urllib.request.urlopen(target_url)
56
+ # for line in data.read():
57
+ # st.write(line)
58
+ # if data is not None:
59
+ # reader = PdfReader(data)
60
+ # for page in reader.pages:
61
+ # text = page.extract_text()
62
+ # text_list.append(text)
63
+ # st.write(text_list)
64
+ # else:
65
+ # st.error("Please upload your own PDF to be analyzed")
66
+ # st.stop()
67
  else:
68
  st.write('Goodbye')