Spaces:
Running
Running
File size: 642 Bytes
0a547e9 0419684 0a547e9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from registration import update_reg
from anvil.tables import app_tables
from PyPDF2 import PdfReader
from io import BytesIO
# from notebook_funcs import get_message
def get_files():
update_reg('get_files')
retval=''
query=app_tables.files.search()
for r in query:
retval+=r['filename']+'\n'
return retval
def get_file(name):
update_reg('get_file')
retval=''
r=app_tables.files.get(filename=name)
bts=r['file'].get_bytes()
sio=BytesIO(bts)
with sio as f:
reader=PdfReader(f)
fpage=reader.pages[0].extract_text()
retval+=r['filename']+'\n'+ fpage
return retval
|