from streamlit import session_state as ss from streamlit_pdf_viewer import pdf_viewer import streamlit_pdf_viewer import streamlit as st # # Declare variable. # if 'pdf_ref' not in ss: # ss.pdf_ref = None # # Access the uploaded ref via a key. # st.file_uploader("Upload PDF file", type=('pdf'), key='pdf') # if ss.pdf: # ss.pdf_ref = ss.pdf # backup # # Now you can access "pdf_ref" anywhere in your app. # if ss.pdf_ref: # binary_data = ss.pdf_ref.getvalue() # pdf_viewer(input=binary_data, width=700) # import base64 # def displayPDF(file): # # Opening file from file path # with open(file, "rb") as f: # base64_pdf = base64.b64encode(f.read()).decode('utf-8') # # Embedding PDF in HTML # pdf_display = f'' # # Displaying File # st.markdown(pdf_display, unsafe_allow_html=True) # displayPDF("../Transformers/Bhagavad-Gita-As-It-Is.pdf") # import streamlit as st # import streamlit_pdf_viewer # def displayPDF(file): # with open(file, "rb") as f: # pdf_bytes = f.read() # streamlit_pdf_viewer.pdf_viewer(pdf_bytes) # displayPDF("../Transformers/Bhagavad-Gita-As-It-Is.pdf") # Arial Unicode.ttf # import streamlit as st # import fitz # PyMuPDF library # from PIL import Image, ImageDraw, ImageFont # import io # import numpy as np # def display_pdf_with_highlight(file_path, keywords): # # Open the PDF file # with fitz.open(file_path) as doc: # # Create a new PDF file to hold the highlighted pages # highlighted_pdf = fitz.open() # # Iterate over each page in the PDF # for page_index in range(len(doc)): # page = doc.load_page(page_index) # pix = page.get_pixmap(dpi=300) # img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) # # Create a drawing object and highlight the keywords # draw = ImageDraw.Draw(img) # font = ImageFont.truetype("Arial Unicode.ttf", 14) # Replace with your desired font # for keyword in keywords: # areas = page.search_for(keyword) # for area in areas: # bbox = area.bbox # draw.rectangle(bbox, outline="yellow", width=3) # # Convert the highlighted image to a NumPy array # img_np = np.asarray(img) # # Create a MuPDF-compatible Pixmap from the NumPy array # muimg = fitz.Pixmap(fitz.csRGB, img_np.shape[1], img_np.shape[0]) # muimg.set_data(img_np.tobytes()) # # Create a new PDF page and insert the highlighted image # new_page = highlighted_pdf.new_page(-1, width=muimg.width, height=muimg.height) # new_page.insert_image(fitz.Rect(0, 0, muimg.width, muimg.height), stream=muimg) # # Create a BytesIO object to hold the highlighted PDF data # pdf_bytes = io.BytesIO() # highlighted_pdf.write(pdf_bytes) # pdf_bytes.seek(0) # # Display the highlighted PDF in Streamlit # st.download_button( # label="Download Highlighted PDF", # data=pdf_bytes.getvalue(), # file_name="highlighted_pdf.pdf", # mime="application/pdf", # ) # # Example usage # file_path = "../Transformers/Bhagavad-Gita-As-It-Is.pdf" # keywords = ["Arjuna", "Krishna"] # display_pdf_with_highlight(file_path, keywords) # import pyperclip # content = str(pyperclip.paste()) # import streamlit as st # import fitz # def annotate_pdf(file_path, text_to_highlight): # # Open the PDF file # with fitz.open(file_path) as doc: # # Create a new PDF file to hold the annotated pages # annotated_pdf = fitz.open() # # Iterate over each page in the PDF # for page_index in range(len(doc)): # page = doc.load_page(page_index) # # Search for the text to highlight # areas = page.search_for(text_to_highlight) # # Add rectangle annotations for the highlighted areas # for area in areas: # page.add_rect_annot(area) # # Create a new PDF page and insert the annotated page # new_page = annotated_pdf.new_page(-1, width=page.rect.width, height=page.rect.height) # new_page.show_pdf_page(page.rect, doc, page_index) # # Create a BytesIO object to hold the annotated PDF data # pdf_bytes = annotated_pdf.write() # # Display the annotated PDF in Streamlit # st.download_button( # label="Download Annotated PDF", # data=pdf_bytes, # file_name="annotated_pdf.pdf", # mime="application/pdf", # ) # # Example usage # file_path = "../Transformers/Bhagavad-Gita-As-It-Is.pdf" # text_to_highlight = "Arjuna" # annotate_pdf(file_path, text_to_highlight) # def displayPDF(file): # # Opening file from file path # with open(file, "rb") as f: # base64_pdf = base64.b64encode(f.read()).decode('utf-8') # # Embedding PDF in HTML # pdf_display = f'' # # Displaying File # st.markdown(pdf_display, unsafe_allow_html=True) # displayPDF("../Transformers/Bhagavad-Gita-As-It-Is.pdf") # import streamlit as st # import fitz # def annotate_pdf(file_path, text_to_highlight): # # Open the PDF file # with fitz.open(file_path) as doc: # # Create a new PDF file to hold the annotated pages # annotated_pdf = fitz.open() # # Iterate over each page in the PDF # for page_index in range(len(doc)): # page = doc.load_page(page_index) # # Search for the text to highlight # areas = page.search_for(text_to_highlight) # # Add rectangle annotations for the highlighted areas # for area in areas: # page.add_rect_annot(area) # # Create a new PDF page and insert the annotated page # new_page = annotated_pdf.new_page(-1, width=page.rect.width, height=page.rect.height) # new_page.show_pdf_page(page.rect, doc, page_index) # # Create a BytesIO object to hold the annotated PDF data # pdf_bytes = annotated_pdf.write() # streamlit_pdf_viewer.pdf_viewer(pdf_bytes) # # Display the annotated PDF in Streamlit # st.download_button( # label="Download Annotated PDF", # data=pdf_bytes, # file_name="annotated_pdf.pdf", # mime="application/pdf", # ) # # Example usage # file_path = "../Transformers/Bhagavad-Gita-As-It-Is.pdf" # text_to_highlight = "Krishna" # annotate_pdf(file_path, text_to_highlight) # import streamlit as st # import fitz # import io # def annotate_pdf(uploaded_file, text_to_highlight): # try: # # Open the PDF file from the file-like object # doc = fitz.open(stream=uploaded_file.read(), filetype="pdf") # # Create a new PDF file to hold the annotated pages # annotated_pdf = fitz.open() # # Iterate over each page in the PDF # for page_index in range(len(doc)): # page = doc.load_page(page_index) # # Search for the text to highlight # areas = page.search_for(text_to_highlight) # # Add rectangle annotations for the highlighted areas # for area in areas: # page.add_rect_annot(area) # # Create a new PDF page and insert the annotated page # new_page = annotated_pdf.new_page(-1, width=page.rect.width, height=page.rect.height) # new_page.show_pdf_page(page.rect, doc, page_index) # # Create a BytesIO object to hold the annotated PDF data # pdf_bytes = io.BytesIO(annotated_pdf.write()) # # Display the annotated PDF in Streamlit # st.download_button( # label="Download Annotated PDF", # data=pdf_bytes.getvalue(), # file_name="annotated_pdf.pdf", # mime="application/pdf", # ) # except Exception as e: # st.error(f"An error occurred: {str(e)}") # # Streamlit app # def main(): # st.title("PDF Annotation App") # uploaded_file = st.file_uploader("Upload a PDF file", type="pdf") # if uploaded_file is not None: # text_to_highlight = st.text_input("Enter text to highlight") # if text_to_highlight: # annotate_pdf(uploaded_file, text_to_highlight) # if __name__ == "__main__": # main() # file_path = "../Transformers/Bhagavad-Gita-As-It-Is.pdf" # text_to_highlight = "Krishna" # annotate_pdf(file_path, text_to_highlight) # import fitz # import base64 # def displayPDF(file): # # Open the PDF document # doc = fitz.open("my_pdf.pdf") # # Get the first page of the document # page = doc.loadPage(4) # # Search for the text string to highlight # text_to_highlight = "Supreme Personality of Godhead" # # Create a rectangle around the text to highlight # highlight_rect = fitz.Rect(page.searchFor(text_to_highlight)[0]) # # Create a highlight annotation # highlight_annot = fitz.Annot(page, highlight_rect, "Highlight", {"color": fitz.utils.getColor("yellow")}) # # Add the annotation to the page # page.addAnnot(highlight_annot) # # Save the document # doc.save("my_pdf_highlighted.pdf") # # Opening file from file path # with open(file, "rb") as f: # base64_pdf = base64.b64encode(f.read()).decode('utf-8') # # Embedding PDF in HTML # pdf_display = f'' # # Displaying File # st.markdown(pdf_display, unsafe_allow_html=True) # displayPDF("../Transformers/Bhagavad-Gita-As-It-Is.pdf") import streamlit as st # import fitz import tempfile # Import the PDF_ANNOT_HIGHLIGHT constant # from fitz.PDF_ANNOT import PDF_ANNOT_HIGHLIGHT import base64 import io def display_highlighted_pdf(file_path, text_to_highlight): # Open the PDF document doc = fitz.open(file_path) # Iterate over each page in the PDF for page_index in range(len(doc)): page = doc.load_page(page_index) # Search for the text string to highlight areas = page.search_for(text_to_highlight) # Create a highlight annotation for each area for area in areas: highlight_rect = fitz.Rect(area) highlight_annot = page.add_highlight_annot(highlight_rect) #fitz.Annot(page.parent, highlight_rect, annot_type=fitz.PDF_ANNOT_HIGHLIGHT) highlight_annot.set_colors({"stroke": fitz.utils.getColor("yellow")}) highlight_annot.update() # page.add_annot(highlight_annot) # Create a BytesIO object to hold the highlighted PDF data # Create a temporary file to save the PDF with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_file_path = temp_file.name doc.save(temp_file_path) # Read the content of the temporary file into a BytesIO object with open(temp_file_path, "rb") as f: pdf_bytes = io.BytesIO(f.read()) # # Remove the temporary file # st.unlink(temp_file_path) # pdf_bytes = io.BytesIO() # doc.write(pdf_bytes) # pdf_bytes.seek(0) # Encode the PDF data as base64 base64_pdf = base64.b64encode(pdf_bytes.getvalue()).decode('utf-8') # Embed the PDF in an HTML iframe pdf_display = f'' # Display the PDF in Streamlit st.markdown(pdf_display, unsafe_allow_html=True) # Example usage file_path = "Bhagavad-Gita-As-It-Is.pdf" text_to_highlight = "Supreme Personality of Godhead" # display_highlighted_pdf(file_path, text_to_highlight) # import streamlit as st # def display_pdf(pdf_path): # # Read the PDF file # with open(pdf_path, "rb") as file: # pdf_bytes = file.read() # # Encode the PDF data as base64 # base64_pdf = base64.b64encode(pdf_bytes).decode("utf-8") # # Embed the PDF in an HTML iframe # pdf_display = f'' # # Display the PDF in Streamlit # st.markdown(pdf_display, unsafe_allow_html=True) # # Example usage # pdf_path = "../Transformers/Bhagavad-Gita-As-It-Is.pdf" # display_pdf(pdf_path) # import pymupdf # # Open the PDF file # doc = pymupdf.open(file_path) # # Get the first page of the PDF # # page = pdf_file.pa # for page in doc: # iterate the document pages # text_coordinates = page.search_for("Bhagavad", quads=True) # # Highlight the text # page.add_highlight_annot(text_coordinates) # # Get the text of the page # text = page.get_text() # # Find the text to highlight # text_to_highlight = "Bhagavad" # # Get the coordinates of the text to highlight # text_coordinates = page.search_for(text_to_highlight) # Highlight the text # page.add_highlight_annot(text_coordinates) # Save the PDF file # doc.save("example_highlighted.pdf") import pymupdf import tempfile import nltk nltk.download('stopwords') from nltk.corpus import stopwords from collections import Counter from streamlit_image_zoom import image_zoom from PIL import Image def highlight_pdf(file_path, text_to_highlight, page_numbers): # Create a temporary file to save the modified PDF # temp_pdf_path = "temp_highlighted_pdf.pdf" # Create a temporary file to save the modified PDF # with tempfile.NamedTemporaryFile(delete=False) as temp_file: # temp_pdf_path = temp_file.name # Open the original PDF doc = pymupdf.open(file_path) pages_to_display = [doc.load_page(page_number - 1) for page_number in page_numbers] # Tokenize the text into words words = text_to_highlight.split() # Remove stopwords stop_words = set(stopwords.words("english")) words = [word for word in words if word.lower() not in stop_words] print(words) # Count the frequency of each word word_counts = Counter(words) # Get the top N most frequent words # top_words = [word for word, _ in word_counts.most_common(5)] # Iterate over each page in the PDF for page in pages_to_display: # Highlight the specified words on the canvas for word in words: highlight_rect = page.search_for(word, quads=True) # Highlight the text # highlight_rect = pymupdf.Rect(word) # highlight_annot = page.add_highlight_annot(highlight_rect) # highlight_annot.set_colors({"stroke": pymupdf.utils.getColor("yellow")}) # highlight_annot.update() page.add_highlight_annot(highlight_rect) # Create a new document with only the specified pages new_doc = pymupdf.open() for page in pages_to_display: new_doc.insert_pdf(doc, from_page=page.number, to_page=page.number) # Save the modified PDF # Save the document to a temporary file with tempfile.NamedTemporaryFile(suffix=".pdf", delete=False) as temp_file: temp_pdf_path = temp_file.name new_doc.save(temp_pdf_path) print(temp_pdf_path) new_doc.save("example_highlighted.pdf") return temp_pdf_path # Example usage def pdf_to_images(pdf_path, page_numbers): doc = fitz.open(pdf_path) images = [] for page_number in page_numbers: page = doc.load_page(page_number - 1) pix = page.get_pixmap() img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) buf = io.BytesIO() img.save(buf, format="PNG") byte_im = buf.getvalue() images.append(byte_im) return images # Function to display PDF in Streamlit def display_highlighted_pdf(): pdf_path = "Bhagavad-Gita-As-It-Is.pdf" sources = [7,8] response_text = "I offer my respectful obeisances unto the lotus feet of my spiritual master and unto the feet of all Vaiñëavas. I offer my respectful" highlighted_pdf_path = highlight_pdf(file_path=file_path, text_to_highlight=response_text, page_numbers=sources) print(highlighted_pdf_path) # with open(highlighted_pdf_path, "rb") as file: # pdf_bytes = file.read() # # Use pdf_viewer to display the PDF in Streamlit # pdf_viewer(pdf_bytes, width=700) images = pdf_to_images(highlighted_pdf_path, sources) for img in images: image_zoom(img) display_highlighted_pdf() # import streamlit as st # import streamlit.components.v1 as components # path_to_html = "https://vedabase.io/en/library/bg/1/1/" # # with open(path_to_html,'r') as f: # # html_data = f.read() # # # Show in webpage # # st.header("Show an external HTML") # # st.components.v1.html(html_data) # try: # with open(path_to_html, 'r') as f: # # Your file processing code here # html_data = f.read() # st.header("Show an external HTML") # st.components.v1.html(html_data) # except FileNotFoundError: # print("File not found. Please check the file path.") # except Exception as e: # print(f"An error occurred: {e}") # import streamlit as st # import requests # from bs4 import BeautifulSoup # def fetch_html(url): # # Fetch the webpage content # response = requests.get(url) # if response.status_code == 200: # return response.content # else: # st.error(f"Failed to fetch webpage. Status code: {response.status_code}") # def scrape_data(html_content): # # Parse HTML content # soup = BeautifulSoup(html_content, "html.parser") # # Scrape data (replace this with your specific scraping logic) # data = soup.find_all(class_="container first-container") # return data # def main(url): # st.title("Webpage Scraper") # # User input for webpage URL # url = st.text_input("Enter the URL of the webpage:", value=url) # # Convert webpage to HTML and scrape data # if st.button("Scrape Data"): # if url: # html_content = fetch_html(url) # str_content = """ """ # if html_content: # data = scrape_data(html_content) # # st.title("HTML Page Display") # # st.components.v1.html(html_content, height=1600, width=800) # # Display scraped data in a new tab # with st.expander("Scraped Data", expanded=True): # for item in data: # # Convert item to string and display # str_content += str(item) # # st.write(str(item)) # # st.title("HTML Page Display") # # st.components.v1.html(data, height=1600, width=800) # # st.title("HTML Page Display") # st.components.v1.html(str_content, height=1600, width=680) # main() # import streamlit as st # html_content = """ #

Bg. 1.1

Devanagari

धृतराष्ट्र उवाच
धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सव: ।
मामका: पाण्डवाश्चैव किमकुर्वत सञ्जय ॥ १ ॥

Text

dhṛtarāṣṭra uvāca
dharma-kṣetre kuru-kṣetre
samavetā yuyutsavaḥ
māmakāḥ pāṇḍavāś caiva
kim akurvata sañjaya

Synonyms

dhṛtarāṣṭraḥ uvāca — King Dhṛtarāṣṭra said; dharma-kṣetre — in the place of pilgrimage; kuru-kṣetre — in the place named Kurukṣetra; samavetāḥ — assembled; yuyutsavaḥ — desiring to fight; māmakāḥ — my party (sons); pāṇḍavāḥ — the sons of Pāṇḍu; ca — and; eva — certainly; kim — what; akurvata — did they do; sañjaya — O Sañjaya.

Translation

Dhṛtarāṣṭra said: O Sañjaya, after my sons and the sons of Pāṇḍu assembled in the place of pilgrimage at Kurukṣetra, desiring to fight, what did they do?

Purport

Bhagavad-gītā is the widely read theistic science summarized in the Gītā-māhātmya (Glorification of the Gītā). There it says that one should read Bhagavad-gītā very scrutinizingly with the help of a person who is a devotee of Śrī Kṛṣṇa and try to understand it without personally motivated interpretations. The example of clear understanding is there in the Bhagavad-gītā itself, in the way the teaching is understood by Arjuna, who heard the Gītā directly from the Lord. If someone is fortunate enough to understand the Bhagavad-gītā in that line of disciplic succession, without motivated interpretation, then he surpasses all studies of Vedic wisdom, and all scriptures of the world. One will find in the Bhagavad-gītā all that is contained in other scriptures, but the reader will also find things which are not to be found elsewhere. That is the specific standard of the Gītā. It is the perfect theistic science because it is directly spoken by the Supreme Personality of Godhead, Lord Śrī Kṛṣṇa.

The topics discussed by Dhṛtarāṣṭra and Sañjaya, as described in the Mahābhārata, form the basic principle for this great philosophy. It is understood that this philosophy evolved on the Battlefield of Kurukṣetra, which is a sacred place of pilgrimage from the immemorial time of the Vedic age. It was spoken by the Lord when He was present personally on this planet for the guidance of mankind.

The word dharma-kṣetra (a place where religious rituals are performed) is significant because, on the Battlefield of Kurukṣetra, the Supreme Personality of Godhead was present on the side of Arjuna. Dhṛtarāṣṭra, the father of the Kurus, was highly doubtful about the possibility of his sons’ ultimate victory. In his doubt, he inquired from his secretary Sañjaya, “What did they do?” He was confident that both his sons and the sons of his younger brother Pāṇḍu were assembled in that Field of Kurukṣetra for a determined engagement of the war. Still, his inquiry is significant. He did not want a compromise between the cousins and brothers, and he wanted to be sure of the fate of his sons on the battlefield. Because the battle was arranged to be fought at Kurukṣetra, which is mentioned elsewhere in the Vedas as a place of worship – even for the denizens of heaven – Dhṛtarāṣṭra became very fearful about the influence of the holy place on the outcome of the battle. He knew very well that this would influence Arjuna and the sons of Pāṇḍu favorably, because by nature they were all virtuous. Sañjaya was a student of Vyāsa, and therefore, by the mercy of Vyāsa, Sañjaya was able to envision the Battlefield of Kurukṣetra even while he was in the room of Dhṛtarāṣṭra. And so, Dhṛtarāṣṭra asked him about the situation on the battlefield.

Both the Pāṇḍavas and the sons of Dhṛtarāṣṭra belong to the same family, but Dhṛtarāṣṭra’s mind is disclosed herein. He deliberately claimed only his sons as Kurus, and he separated the sons of Pāṇḍu from the family heritage. One can thus understand the specific position of Dhṛtarāṣṭra in his relationship with his nephews, the sons of Pāṇḍu. As in the paddy field the unnecessary plants are taken out, so it is expected from the very beginning of these topics that in the religious field of Kurukṣetra, where the father of religion, Śrī Kṛṣṇa, was present, the unwanted plants like Dhṛtarāṣṭra’s son Duryodhana and others would be wiped out and the thoroughly religious persons, headed by Yudhiṣṭhira, would be established by the Lord. This is the significance of the words dharma-kṣetre and kuru-kṣetre, apart from their historical and Vedic importance.

# """ # st.title("HTML Page Display") # st.components.v1.html(html_content, height=1600, width=800) # import requests # from bs4 import BeautifulSoup # # URL of the webpage # baseurl = "https://vedabase.io/en/library/bg/" # # Fetch the webpage content # response = requests.get(baseurl) # if response.status_code == 200: # html_content = response.content # # Parse HTML content # soup = BeautifulSoup(html_content, "html.parser") # # Find all direct child div elements with class="r-chapter" # direct_child_div_elements = soup.select("div.col-12 > div.r-chapter") # # List to store the extracted text # output = [] # # Iterate over each direct child div element # for div in direct_child_div_elements: # # Find the tag within the div # a_tag = div.find("a") # if a_tag: # # Extract the text from the tag and append it to the output list # output.append(a_tag.text.strip()) # # Print the output list # # print(output) # # print(len(output)) # ### Link to all chapters # import re # # Sample text # chapter = output[4] # text_to_number = { # "One": "1", # "Two": "2", # "Three": "3", # "Four": "4", # "Five": "5", # "Six": "6", # "Seven": "7", # "Eight": "8", # "Nine": "9", # "Ten": "10", # # Add more numbers if needed # } # # Split the text by spaces # words = chapter.split() # # Find the text representing the number # number_text = words[1].strip(":") # Assuming the number text is the second word # # Extract the numeric part # chapter_number = text_to_number[number_text] # # Print the chapter number # # print(chapter_number) # url = baseurl + chapter_number # # print(url) # ### all Texts in each chapter # response = requests.get(url) # if response.status_code == 200: # html_content = response.content # # Parse HTML content # text = BeautifulSoup(html_content, "html.parser") # # print(text) # # Find all direct child div elements with class="r-chapter" # direct_child_div_elements = text.select("div.col-12 > dl.r.r-verse") # # print(direct_child_div_elements) # # List to store the extracted text # text_number = [] # # Iterate over each direct child div element # for div in direct_child_div_elements: # # Find the tag within the div # a_tag = div.find("a") # if a_tag: # # Extract the text from the tag and append it to the output list # text_number.append(a_tag.text.strip()) # # Print the output list # # print(text_number) # # print(len(text_number)) # ### link to each Text in each chapter # text_page = text_number[0] # # Split the text by spaces # words = text_page.split() # # Find the text representing the number # text_number = words[1].strip(":") # Assuming the number text is the second word # # print(f"chapter_number - {chapter_number} : text_number - {text_number}") # texturl = baseurl + chapter_number + "/" + text_number # # print(texturl) # main(url=texturl) # st.title("Display HTML File in Streamlit") # # Path to the HTML file # html_file_path = "../Transformers/Bg. 1.1.html" # try: # # Read the HTML file # with open(html_file_path, "r", encoding="utf-8") as file: # html_content = file.read() # # Display the HTML content using the 'st.components.v1.html' component # expanded = st.checkbox("Expand HTML page") # if expanded: # st.components.v1.html(html_content, height=1600, width=680) # else: # st.components.v1.html(html_content, height=600) # except FileNotFoundError: # st.error(f"HTML file '{html_file_path}' not found!") # import streamlit as st # st.title("Streamlit Tabs Example") # # Add tabs to the sidebar # tabs = st.sidebar.radio("Navigation", ["Home", "About", "Settings"]) # # Display different content based on the selected tab # if tabs == "Home": # st.header("Home Page") # st.write("Welcome to the Home page!") # elif tabs == "About": # st.header("About Page") # st.write("This is the About page.") # elif tabs == "Settings": # st.header("Settings Page") # st.write("Here you can configure your settings.") # st.title("Netflix-like Grid Display") # import streamlit as st # import os # import streamlit.components.v1 as components # # Define movie data # movies = [ # {"title": "Movie 1", "poster_path": "../Transformers/Bg. 1.1.html"}, # {"title": "Movie 2", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 3", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 4", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 5", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 6", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 7", "poster_url": "https://via.placeholder.com/150"}, # {"title": "Movie 8", "poster_url": "https://via.placeholder.com/150"}, # ] # Display movies in a grid # num_columns = 4 # col_count = 0 # cols = st.columns(num_columns) # expanded = st.checkbox("Expand HTML page") # for movie in movies: # with cols[col_count % num_columns]: # st.markdown(f"

{movie['title']}

", unsafe_allow_html=True) # st.write(f"Placeholder for {movie['title']}") # if 'poster_path' in movie: # # Convert local file path to URL # poster_url = f"file://{os.path.abspath(movie['poster_path'])}" # print(poster_url) # # Display the HTML page using IFrame # if expanded: # components.iframe(poster_url, width=800, height=600) # else: # components.iframe(poster_url,width=200) # else: # # Display placeholder image # st.image(movie["poster_url"], width=200) # col_count += 1