amornpan commited on
Commit
2b88de7
1 Parent(s): 3c6e45d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -36
app.py CHANGED
@@ -22,14 +22,6 @@ import requests
22
  import os
23
  import re
24
 
25
- # Access the variable 'eRAG_access_token'
26
- access_token = os.getenv('eRAG_access_token')
27
-
28
- # Correct way to use the access token value
29
- headers = {
30
- "Authorization": f"Bearer {access_token}" # Using f-string
31
- }
32
-
33
  st.title('eRAG-PDPA-v1')
34
 
35
  st.markdown("""
@@ -75,35 +67,13 @@ def display_search_result(result, index):
75
  <pre>{}</pre>
76
  </div>
77
  """.format(result['text']), unsafe_allow_html=True)
 
 
78
 
79
- try:
80
- pdf_path = result['file_path']
81
- if os.path.exists(pdf_path):
82
- st.markdown("#### 📄 PDF Preview (with highlighted text)")
83
-
84
- highlighted_pdf = create_highlighted_pdf(
85
- pdf_path,
86
- result['text'],
87
- result['metadata']['page_label']
88
- )
89
-
90
- if highlighted_pdf:
91
- base64_pdf = base64.b64encode(highlighted_pdf).decode('utf-8')
92
- pdf_display = f'''
93
- <iframe
94
- src="data:application/pdf;base64,{base64_pdf}"
95
- width="100%"
96
- height="800px"
97
- type="application/pdf"
98
- style="border: 1px solid #ccc; border-radius: 5px;"
99
- ></iframe>
100
- '''
101
- st.markdown(pdf_display, unsafe_allow_html=True)
102
- else:
103
- st.error("Failed to create highlighted PDF")
104
- except Exception as e:
105
- st.error(f"Error displaying PDF: {str(e)}")
106
-
107
  # Custom styles for Streamlit inputs
108
  st.markdown("""
109
  <style>
 
22
  import os
23
  import re
24
 
 
 
 
 
 
 
 
 
25
  st.title('eRAG-PDPA-v1')
26
 
27
  st.markdown("""
 
67
  <pre>{}</pre>
68
  </div>
69
  """.format(result['text']), unsafe_allow_html=True)
70
+ # Access the variable 'eRAG_access_token'
71
+ access_token = os.getenv('eRAG_access_token')
72
 
73
+ # Correct way to use the access token value
74
+ headers = {
75
+ "Authorization": f"Bearer {access_token}" # Using f-string
76
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # Custom styles for Streamlit inputs
78
  st.markdown("""
79
  <style>