ariankhalfani commited on
Commit
99287f5
·
verified ·
1 Parent(s): 49e0436

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  import requests
3
  import streamlit as st
4
- import PyPDF2
5
 
6
  # Get the Hugging Face API Token from environment variables
7
  HF_API_TOKEN = os.getenv("HF_API_KEY")
@@ -19,10 +19,8 @@ def query_model(api_url, payload):
19
 
20
  def extract_pdf_text(uploaded_file):
21
  pdf_text = ""
22
- pdf_reader = PyPDF2.PdfFileReader(uploaded_file)
23
- num_pages = pdf_reader.numPages
24
- for page_num in range(num_pages):
25
- page = pdf_reader.getPage(page_num)
26
  pdf_text += page.extract_text()
27
  return pdf_text
28
 
 
1
  import os
2
  import requests
3
  import streamlit as st
4
+ from PyPDF2 import PdfReader
5
 
6
  # Get the Hugging Face API Token from environment variables
7
  HF_API_TOKEN = os.getenv("HF_API_KEY")
 
19
 
20
  def extract_pdf_text(uploaded_file):
21
  pdf_text = ""
22
+ pdf_reader = PdfReader(uploaded_file)
23
+ for page in pdf_reader.pages:
 
 
24
  pdf_text += page.extract_text()
25
  return pdf_text
26