writ_fil / app.py
Seetha's picture
Update app.py
db19b4e
raw
history blame
3 kB
# import urllib.request
# import streamlit as st
# import os
# from datasets import load_from_disk
# import requests
# with urllib.request.urlopen('https://huggingface.co/datasets/Seetha/Visualization') as response:
# data = response.read()
# with open('./level2.json','r+') as fi:
# data = fi.read()
# st.write('before change', data)
# fi.seek(0)
# fi.write('Hello world!')
# fi.truncate()
# st.write(os.path.abspath("./level2.json"))
# with open('./level2.json','w') as dat:
# dat.write('hello hello')
# #st.write(data_after)
# # bin_file = open('./level2.json', 'rb')
# # # Execute the request
# # response = requests.post('https://huggingface.co/datasets/Seetha/Visualization', files={'file': bin_file})
# # # Close the file
# # bin_file.close()
# from datasets import load_dataset
# # Load the dataset
# dataset = load_dataset("Seetha/Visualization")
# # Make changes to the dataset
# # ...
# # Save the changed dataset to a file
# dataset.save_to_disk('./level.json')
# # In your Streamlit app, load the dataset from the file
# dataset = load_dataset('json', data_files='./level.json')
import streamlit as st
import urllib # the lib that handles the url stuff
from PyPDF2 import PdfReader
import base64
text_list = []
#target_url = 'https://huggingface.co/datasets/Seetha/Visualization/raw/main/AFLAC_Wyatt_notag.pdf'
file_path = "AFLAC_Wyatt_notag.pdf"
file_path1 = "USB_Golnaz_Alice.pdf"
col1, col2 = st.columns([1,1])
with col1:
if st.button('AFLAC_Wyatt'):
with open(file_path,"rb") as f:
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf">'
st.markdown(pdf_display, unsafe_allow_html=True)
visual_display = f'<iframe src="https://seetha-aflac-wyat.hf.space" frameborder="0" width="1000" height="500"></iframe>'
st.markdown(visual_display, unsafe_allow_html=True)
with col2:
if st.button('USB_GOLNAZ_ALICE'):
with open(file_path1,"rb") as f:
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf"></iframe>'
st.markdown(pdf_display, unsafe_allow_html=True)
visual_display = f'<iframe src="https://seetha-usb-golnaz-alice.hf.space" frameborder="0" width="1000" height="500"></iframe>'
st.markdown(visual_display, unsafe_allow_html=True)
# data = urllib.request.urlopen(target_url)
# for line in data.read():
# st.write(line)
# if data is not None:
# reader = PdfReader(data)
# for page in reader.pages:
# text = page.extract_text()
# text_list.append(text)
# st.write(text_list)
# else:
# st.error("Please upload your own PDF to be analyzed")
# st.stop()
# else:
# st.write('Goodbye')