Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import random
|
|
| 6 |
import base64
|
| 7 |
import json
|
| 8 |
import pycountry
|
|
|
|
| 9 |
from PIL import Image
|
| 10 |
import streamlit as st
|
| 11 |
from langdetect import detect
|
|
@@ -464,8 +465,12 @@ def display_source_documents_with_images(source_documents, query):
|
|
| 464 |
highlighted_snippet = highlight_query_words(snippet, query)
|
| 465 |
|
| 466 |
st.markdown(f'<div class="source-content">{highlighted_snippet}</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
| 467 |
# Define the base URL for Hugging Face Spaces (replace this with your actual space URL)
|
| 468 |
BASE_URL = "https://huggingface.co/spaces/bacancydataprophets/Smart-PDF-Search/"
|
|
|
|
| 469 |
# Construct the full URL
|
| 470 |
url = f"{BASE_URL}?page=pdf_details&filename={pdf_name}&page_number={page_number}"
|
| 471 |
|
|
@@ -646,6 +651,10 @@ def main():
|
|
| 646 |
query_params = st.query_params
|
| 647 |
page = query_params.get('page', 'home')
|
| 648 |
logger.debug(f"Current page: {page}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 649 |
|
| 650 |
# Routing logic
|
| 651 |
if page == 'pdf_details':
|
|
|
|
| 6 |
import base64
|
| 7 |
import json
|
| 8 |
import pycountry
|
| 9 |
+
import urllib.parse
|
| 10 |
from PIL import Image
|
| 11 |
import streamlit as st
|
| 12 |
from langdetect import detect
|
|
|
|
| 465 |
highlighted_snippet = highlight_query_words(snippet, query)
|
| 466 |
|
| 467 |
st.markdown(f'<div class="source-content">{highlighted_snippet}</div>', unsafe_allow_html=True)
|
| 468 |
+
|
| 469 |
+
pdf_name = urllib.parse.quote(pdf_name)
|
| 470 |
+
|
| 471 |
# Define the base URL for Hugging Face Spaces (replace this with your actual space URL)
|
| 472 |
BASE_URL = "https://huggingface.co/spaces/bacancydataprophets/Smart-PDF-Search/"
|
| 473 |
+
|
| 474 |
# Construct the full URL
|
| 475 |
url = f"{BASE_URL}?page=pdf_details&filename={pdf_name}&page_number={page_number}"
|
| 476 |
|
|
|
|
| 651 |
query_params = st.query_params
|
| 652 |
page = query_params.get('page', 'home')
|
| 653 |
logger.debug(f"Current page: {page}")
|
| 654 |
+
|
| 655 |
+
encoded_filename = query_params.get('filename', '')
|
| 656 |
+
filename = urllib.parse.unquote(encoded_filename)
|
| 657 |
+
page_number = int(query_params.get('page_number', 0))
|
| 658 |
|
| 659 |
# Routing logic
|
| 660 |
if page == 'pdf_details':
|